import Field from "../../components/Field" import React, {FormEvent, useState} from "react" import {useNavigate, useParams} from "react-router-dom" import useAuthUser from "../../hooks/AuthUser" import useAxiosTools from "../../hooks/AxiosTools" const Reset = () => { const {token} = useParams() const navigate = useNavigate() const {setAuthUser} = useAuthUser() const [email, setEmail] = useState('') const [password, setPassword] = useState('') const [samePassword, setSamePassword] = useState('') const {errorCatch, errorLabel, cleanErrors, axiosGet, axiosPost} = useAxiosTools() const handleSubmit = async (event: FormEvent) => { event.preventDefault() try { cleanErrors() await axiosGet('/sanctum/csrf-cookie') const res = await axiosPost('/api/reset', {email, token, password, samePassword}) setAuthUser(res.data.user) navigate('/connexion') } catch (e) { errorCatch(e) } } return