add more validations
This commit is contained in:
33
frontend/src/app/hooks/useCredentialForm.jsx
Normal file
33
frontend/src/app/hooks/useCredentialForm.jsx
Normal file
@@ -0,0 +1,33 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
|
||||
const useCredentialForm = () => {
|
||||
const [triggerAlert, setTriggerAlert] = useState(false);
|
||||
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
watch,
|
||||
formState: { errors },
|
||||
} = useForm();
|
||||
|
||||
const onSubmit = (data) => {
|
||||
setTriggerAlert(true);
|
||||
|
||||
console.log("Submitted data:", data);
|
||||
};
|
||||
|
||||
return {
|
||||
register,
|
||||
handleSubmit,
|
||||
watch,
|
||||
errors,
|
||||
onSubmit,
|
||||
triggerAlert,
|
||||
setTriggerAlert,
|
||||
};
|
||||
};
|
||||
|
||||
export default useCredentialForm;
|
||||
Reference in New Issue
Block a user