import React, { useState, useEffect } from 'react'; import { AiOutlineSend } from 'react-icons/ai'; import { useNavigate } from 'react-router-dom'; import AuthService from '../services/AuthService'; import '../Style/Global.css'; import {basePath} from "../AdressSetup" const SignUp = () => { const navigate = useNavigate(); const [error, setError] = useState(null); const [showConfirmation, setShowConfirmation] = useState(false); const handleSubmit = async (event: React.FormEvent) => { event.preventDefault(); try { const data = { pseudo: (event.target as any).pseudo.value, password: (event.target as any).password.value, Cpassword: (event.target as any).Cpassword.value, }; const validation = await AuthService.validateSignUp(data); if (!validation.valid) { setError(validation.error); } else { setError(null); const result = await AuthService.signUp(data); console.log(result); setShowConfirmation(true); setTimeout(() => { navigate(`${basePath}/login`); // 3 secondes avant de rediriger vers la page de connexion }, 1250); } } catch (error: any) { setError(error.message); } }; useEffect(() => { return () => { setShowConfirmation(false); }; }, []); return (

Sign Up

Vous avez déjà un compte ?

{error && (
{error}
)} {showConfirmation && (
Inscription réussie ! Vous serez redirigé vers la page de connexion.
)}
); }; export default SignUp;