import Icons from "@/components/ui/icons"; import Modal from "@/components/ui/modal"; import { SelectField } from "@/components/ui/select"; import { useZForm } from "@/hooks/useZForm"; import { createDisclosure } from "@/lib/utils"; import React from "react"; import { ScrollView, XStack } from "tamagui"; import { FormSchema, formSchema, typeOptions } from "../schema/form"; import { InputField } from "@/components/ui/input"; import FormField from "@/components/ui/form"; import { useSaveKeychain } from "../hooks/query"; import { ErrorAlert } from "@/components/ui/alert"; import Button from "@/components/ui/button"; import { UserTypeInputFields, PVETypeInputFields, RSATypeInputFields, CertTypeInputFields, } from "./input-fields"; export const keyFormModal = createDisclosure(); const KeyForm = () => { const { data } = keyFormModal.use(); const form = useZForm(formSchema, data); const isEditing = data?.id != null; const type = form.watch("type"); const saveMutation = useSaveKeychain(); const onSubmit = form.handleSubmit((values) => { saveMutation.mutate(values, { onSuccess: () => { keyFormModal.onClose(); form.reset(); }, }); }); return ( {type === "user" ? ( ) : type === "pve" ? ( ) : type === "rsa" ? ( ) : type === "cert" ? ( ) : null} ); }; export default KeyForm;