From eb7da996a7c2d617d276f296cac07a6fd5648664 Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Sun, 27 Oct 2024 12:03:14 +0000 Subject: ui: Redesign the settings page and move it to its own layout --- .../components/dashboard/settings/AddApiKey.tsx | 157 --------------------- 1 file changed, 157 deletions(-) delete mode 100644 apps/web/components/dashboard/settings/AddApiKey.tsx (limited to 'apps/web/components/dashboard/settings/AddApiKey.tsx') diff --git a/apps/web/components/dashboard/settings/AddApiKey.tsx b/apps/web/components/dashboard/settings/AddApiKey.tsx deleted file mode 100644 index 34fd2df7..00000000 --- a/apps/web/components/dashboard/settings/AddApiKey.tsx +++ /dev/null @@ -1,157 +0,0 @@ -"use client"; - -import type { SubmitErrorHandler } from "react-hook-form"; -import { useState } from "react"; -import { useRouter } from "next/navigation"; -import { ActionButton } from "@/components/ui/action-button"; -import { Button } from "@/components/ui/button"; -import CopyBtn from "@/components/ui/copy-button"; -import { - Dialog, - DialogClose, - DialogContent, - DialogDescription, - DialogFooter, - DialogHeader, - DialogTitle, - DialogTrigger, -} from "@/components/ui/dialog"; -import { - Form, - FormControl, - FormDescription, - FormField, - FormItem, - FormLabel, - FormMessage, -} from "@/components/ui/form"; -import { Input } from "@/components/ui/input"; -import { toast } from "@/components/ui/use-toast"; -import { api } from "@/lib/trpc"; -import { zodResolver } from "@hookform/resolvers/zod"; -import { useForm } from "react-hook-form"; -import { z } from "zod"; - -function ApiKeySuccess({ apiKey }: { apiKey: string }) { - return ( -
-
- Note: please copy the key and store it somewhere safe. Once you close - the dialog, you won't be able to access it again. -
-
- - { - return apiKey; - }} - /> -
-
- ); -} - -function AddApiKeyForm({ onSuccess }: { onSuccess: (key: string) => void }) { - const formSchema = z.object({ - name: z.string(), - }); - const router = useRouter(); - const mutator = api.apiKeys.create.useMutation({ - onSuccess: (resp) => { - onSuccess(resp.key); - router.refresh(); - }, - onError: () => { - toast({ description: "Something went wrong", variant: "destructive" }); - }, - }); - - const form = useForm>({ - resolver: zodResolver(formSchema), - }); - - async function onSubmit(value: z.infer) { - mutator.mutate({ name: value.name }); - } - - const onError: SubmitErrorHandler> = (errors) => { - toast({ - description: Object.values(errors) - .map((v) => v.message) - .join("\n"), - variant: "destructive", - }); - }; - - return ( -
- - { - return ( - - Name - - - - - Give your API key a unique name - - - - ); - }} - /> - - Create - - - - ); -} - -export default function AddApiKey() { - const [key, setKey] = useState(undefined); - const [dialogOpen, setDialogOpen] = useState(false); - return ( - - - - - - - - {key ? "Key was successfully created" : "Create API key"} - - - {key ? ( - - ) : ( - - )} - - - - - - - - - - ); -} -- cgit v1.2.3-70-g09d2