diff --git a/components/providers/add-provider.tsx b/components/providers/add-provider.tsx index 3033f8b904..01e85db980 100644 --- a/components/providers/add-provider.tsx +++ b/components/providers/add-provider.tsx @@ -1,39 +1,20 @@ "use client"; -import { useState } from "react"; - import { AddIcon } from "../icons"; -import { CustomAlertModal, CustomButton } from "../ui/custom"; -import { AddForm } from "./forms"; +import { CustomButton } from "../ui/custom"; export const AddProvider = () => { - const [isAddOpen, setIsAddOpen] = useState(false); - return ( - <> - + } > - - - -
- setIsAddOpen(true)} - endContent={} - > - Add Account - -
- + Add Account + + ); }; diff --git a/components/providers/forms/add-form.tsx b/components/providers/forms/add-form.tsx deleted file mode 100644 index 3529995cfa..0000000000 --- a/components/providers/forms/add-form.tsx +++ /dev/null @@ -1,127 +0,0 @@ -"use client"; - -import { zodResolver } from "@hookform/resolvers/zod"; -import { Dispatch, SetStateAction } from "react"; -import { useForm } from "react-hook-form"; -import * as z from "zod"; - -import { addProvider } from "@/actions/providers"; -import { SaveIcon } from "@/components/icons"; -import { useToast } from "@/components/ui"; -import { CustomButton, CustomInput } from "@/components/ui/custom"; -import { Form } from "@/components/ui/form"; -import { addProviderFormSchema } from "@/types"; - -import { RadioGroupProvider } from "../radio-group-provider"; - -export const AddForm = ({ - setIsOpen, -}: { - setIsOpen: Dispatch>; -}) => { - const formSchema = addProviderFormSchema; - - const form = useForm>({ - resolver: zodResolver(formSchema), - defaultValues: { - providerType: "", - providerId: "", - providerAlias: "", - }, - }); - - const { toast } = useToast(); - - const isLoading = form.formState.isSubmitting; - - const onSubmitClient = async (values: z.infer) => { - const formData = new FormData(); - - Object.entries(values).forEach( - ([key, value]) => value !== undefined && formData.append(key, value), - ); - - const data = await addProvider(formData); - - if (data?.errors && data.errors.length > 0) { - const error = data.errors[0]; - const errorMessage = `${error.detail}`; - // show error - toast({ - variant: "destructive", - title: "Oops! Something went wrong", - description: errorMessage, - }); - } else { - toast({ - title: "Success!", - description: "The provider was updated successfully.", - }); - setIsOpen(false); // Close the modal on success - } - }; - - return ( -
- - - - - -
- setIsOpen(false)} - isDisabled={isLoading} - > - Cancel - - - } - > - {isLoading ? <>Loading : Confirm} - -
- - - ); -}; diff --git a/components/providers/forms/index.ts b/components/providers/forms/index.ts index 6b31209f91..a081952ade 100644 --- a/components/providers/forms/index.ts +++ b/components/providers/forms/index.ts @@ -1,3 +1,2 @@ -export * from "./add-form"; export * from "./delete-form"; export * from "./edit-form";