import { Button, Container, createStyles, Group, Paper, PasswordInput, Text, Title, } from "@mantine/core"; import { useForm, yupResolver } from "@mantine/form"; import { useRouter } from "next/router"; import { FormattedMessage } from "react-intl"; import * as yup from "yup"; import useTranslate from "../../../hooks/useTranslate.hook"; import authService from "../../../services/auth.service"; import toast from "../../../utils/toast.util"; const useStyles = createStyles((theme) => ({ control: { [theme.fn.smallerThan("xs")]: { width: "100%", }, }, })); const ResetPassword = () => { const { classes } = useStyles(); const router = useRouter(); const t = useTranslate(); const form = useForm({ initialValues: { password: "", }, validate: yupResolver( yup.object().shape({ password: yup .string() .min(8, t("common.error.too-short", { length: 8 })) .required(t("common.error.field-required")), }), ), }); const resetPasswordToken = router.query.resetPasswordToken as string; return ( <FormattedMessage id="resetPassword.text.resetPassword" />
{ authService .resetPassword(resetPasswordToken, values.password) .then(() => { toast.success(t("resetPassword.notify.passwordReset")); router.push("/auth/signIn"); }) .catch(toast.axiosError); })} >
); }; export default ResetPassword;