import React, {FormEvent, SyntheticEvent, useState} from "react" import Field from "../../components/Field"; import axios from "axios"; import {Link, useNavigate} from "react-router-dom"; import useAuthUser from "../../hooks/AuthUser"; import Card from "../../components/Card"; import useAxiosTools from "../../hooks/AxiosTools"; const Login = () => { const navigate = useNavigate() const {setAuthUser} = useAuthUser() const [email, setEmail] = useState('') const [password, setPassword] = 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/login', {email, password}) setAuthUser(res.data.user) navigate('/') } catch (e) { errorCatch(e) } } return

Connexion

{errorLabel()} setEmail(event.target.value)} autoFocus>Email setPassword(event.target.value)}>Mot de passe Mot de passe oubliƩ ?
} export default Login