import type { FunctionComponent } from "react"; import { useMutation } from "blitz"; import { useForm } from "react-hook-form"; import Alert from "../../../core/components/alert"; import Button from "../button"; import SettingsSection from "../settings-section"; import appLogger from "../../../../integrations/logger"; import changePassword from "../../mutations/change-password"; const logger = appLogger.child({ module: "update-password" }); type Form = { currentPassword: string; newPassword: string; }; const UpdatePassword: FunctionComponent = () => { const [changePasswordMutation, { error, isError, isSuccess }] = useMutation(changePassword); const { register, handleSubmit, formState: { isSubmitting }, } = useForm
); }; export default UpdatePassword; function parseErrorMessage(error: Error | null): string { if (!error) { return ""; } if (error.name === "ZodError") { return JSON.parse(error.message)[0].message; } return error.message; }