import { useState } from 'react'; /** * A custom React hook for managing form state and input changes. * @param {object} initialValues - An object of initial form field values. * @returns {object} An object containing form values, handleChange function, and resetForm function. */ function useForm(initialValues) { const [values, setValues] = useState(initialValues); const handleChange = (event) => { const { name, value, type, checked } = event.target; setValues({ ...values, [name]: type === 'checkbox' ? checked : value, }); }; const resetForm = () => { setValues(initialValues); }; return { values, handleChange, resetForm, setValues // Expose setValues for external updates if needed }; }