import { Button } from "@/components/ui/button"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, } from "@/components/ui/dialog"; import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage, } from "@/components/ui/form"; import { Input } from "@/components/ui/input"; import { api } from "@/utils/api"; import { zodResolver } from "@hookform/resolvers/zod"; import { AlertTriangle, Container } from "lucide-react"; import { useRouter } from "next/router"; import { useEffect, useState } from "react"; import { useForm } from "react-hook-form"; import { z } from "zod"; const AddRegistrySchema = z.object({ registryName: z.string().min(1, { message: "Registry name is required", }), username: z.string().min(1, { message: "Username is required", }), password: z.string().min(1, { message: "Password is required", }), registryUrl: z.string().min(1, { message: "Registry URL is required", }), }); type AddRegistry = z.infer; export const AddRegistry = () => { const utils = api.useUtils(); const [isOpen, setIsOpen] = useState(false); const { mutateAsync, error, isError } = api.project.create.useMutation(); const router = useRouter(); const form = useForm({ defaultValues: { username: "", password: "", registryUrl: "", }, resolver: zodResolver(AddRegistrySchema), }); useEffect(() => { form.reset({ username: "", password: "", registryUrl: "", }); }, [form, form.reset, form.formState.isSubmitSuccessful]); const onSubmit = async (data: AddRegistry) => { // await mutateAsync({ // name: data.name, // description: data.description, // }) // .then(async (data) => { // await utils.project.all.invalidate(); // toast.success("Project Created"); // setIsOpen(false); // router.push(`/dashboard/project/${data.projectId}`); // }) // .catch(() => { // toast.error("Error to create a project"); // }); }; return ( Add a external registry Fill the next fields to add a external registry. {isError && (
{error?.message}
)}
( Registry Name )} />
( Username )} />
( Password )} />
( Registry URL )} />
); };