import { useNavigate } from "react-router-dom";
const navigate = useNavigate();
const submitHandler = async (event) => {
event.preventDefault();
try {
await submitForm();
navigate("/success"); // Omit optional second argument
} catch (error) {
navigate("/error", { state: { message: "Failed to submit form" } }); // Pass optional second argument
}
};