import { Button, Container, createStyles, Group, Paper, PasswordInput, Text, Title, } from "@mantine/core"; import { useForm, yupResolver } from "@mantine/form"; import { useRouter } from "next/router"; import * as yup from "yup"; 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 form = useForm({ initialValues: { password: "", }, validate: yupResolver( yup.object().shape({ password: yup.string().min(8).required(), }) ), }); const resetPasswordToken = router.query.resetPasswordToken as string; return ( Reset password Enter your new password
{ authService .resetPassword(resetPasswordToken, values.password) .then(() => { toast.success("Your password has been reset successfully."); router.push("/auth/signIn"); }) .catch(toast.axiosError); })} >
); }; export default ResetPassword;