From 29f5611f5fa710c76781e61f49b7399e0dae1f47 Mon Sep 17 00:00:00 2001 From: Defreitasnicolas Date: Tue, 6 Feb 2024 11:03:20 +0100 Subject: [PATCH] mise en place redirection signup avec use navigate --- frontend/src/pages/auth/Signup.jsx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/frontend/src/pages/auth/Signup.jsx b/frontend/src/pages/auth/Signup.jsx index 16453f2..8e97c3e 100644 --- a/frontend/src/pages/auth/Signup.jsx +++ b/frontend/src/pages/auth/Signup.jsx @@ -1,5 +1,5 @@ import React, { useState } from "react"; -import { Link } from "react-router-dom"; +import { useNavigate } from "react-router-dom"; import { ToastContainer, toast } from "react-toastify"; import InputComponents from "../../components/input/InputComponents"; import connexion from "../../services/connexion"; @@ -7,12 +7,17 @@ import "react-toastify/dist/ReactToastify.css"; import ImageLogin from "../../assets/imageLogin2.png"; function Signup() { + const navigate = useNavigate(); const [formValue, setFormValue] = useState({ username: "", email: "", password: "", }); + const handleClick = () => { + navigate("/login"); + }; + const handleChange = (e) => { const { name, value } = e.target; setFormValue((prevData) => ({ @@ -26,6 +31,9 @@ function Signup() { try { await connexion.post("/players", formValue); toast.success("Vous etes inscrit"); + setTimeout(() => { + handleClick(); + }, 2000); } catch (error) { console.error("Erreur lors de l'inscription :", error); toast.error("Erreur lors de l'inscription"); @@ -70,11 +78,9 @@ function Signup() { maxLength={25} />
- - - +