Skip to content

Commit

Permalink
mise en place redirection signup avec use navigate
Browse files Browse the repository at this point in the history
  • Loading branch information
Defreitasnicolas committed Feb 6, 2024
1 parent 6eb6eb3 commit 29f5611
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions frontend/src/pages/auth/Signup.jsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
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";
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) => ({
Expand All @@ -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");
Expand Down Expand Up @@ -70,11 +78,9 @@ function Signup() {
maxLength={25}
/>
<div className="inputSubmitContainer">
<Link to="/login">
<button className="inputSubmit" type="submit">
Inscription
</button>
</Link>
<button className="inputSubmit" type="submit">
Inscription
</button>
</div>
</form>
</div>
Expand Down

0 comments on commit 29f5611

Please sign in to comment.