import { Form, Formik, Field } from "formik"; import FormGroup from "../components/FormGroup"; import type { NPEDErrorValues, NPEDFieldType } from "../../../types/types"; import { useNPEDAuth } from "../../../hooks/useNPEDAuth"; import { toast } from "sonner"; const NPEDFields = () => { const { signIn } = useNPEDAuth(); const initialValues = { username: "", password: "", clientId: "", frontId: "NPEDFront", rearId: "NPEDRear", }; const handleSubmit = (values: NPEDFieldType) => { const valuesToSend = { ...values, }; signIn(valuesToSend); toast("Signed in successfully"); }; const validateValues = (values: NPEDFieldType) => { const errors: NPEDErrorValues = {}; if (!values.username) errors.username = "Required"; if (!values.password) errors.password = "Required"; if (!values.clientId) errors.clientId = "Required"; return errors; }; return ( {({ errors, touched }) => (
{touched.username && errors.username && ( {errors.username} )} {touched.password && errors.password && ( {errors.password} )} {touched.clientId && errors.clientId && ( {errors.clientId} )}
)}
); }; export default NPEDFields;