Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recup connexion #45

Merged
merged 3 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions frontend/src/pages/Connection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,5 @@ function Connection() {
}

export default Connection;


31 changes: 23 additions & 8 deletions frontend/src/pages/Inscription.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useState } from "react";
import { NavLink } from "react-router-dom";
import axios from "axios";
import LogoContainer from "../components/LogoContainer";

Expand All @@ -11,8 +12,14 @@ function Inscription() {
civility: "",
naissance: "",
});
const [error, setError] = useState(false);
const [succes, setSucces] = useState(false);

// const { updateUser, user: connectedUser } = useUser();
const [showModal, setShowModal] = useState(false);
// const navigate = useNavigate();

const toggleModal = () => {
setShowModal(!showModal);
};

const handleInputChange = (e) => {
const { name, value } = e.target;
Expand All @@ -33,22 +40,19 @@ function Inscription() {
const result = await axios.post("http://localhost:3310/api/users", user);
// console.log(user);
if (result.status === 201) {
setSucces(true);
} else {
setError(true);
toggleModal(); // Afficher la modale en cas de succès
// updateUser(result.data);
// navigate("/");
}

// console.log("Request URL:", url);
// console.log("User registered successfully");
} catch (someError) {
setError(true);
console.error("Error during registration:", someError);
}
};
return (
<div className="signUpPageMockupGuest">
{error && <h1 style={{ color: "red", fontSize: 12 }}>Error</h1>}
{succes && <h1 style={{ color: "green", fontSize: 12 }}>Sicces</h1>}
<div className="searchDisplaySection">
<LogoContainer />
<div className="form">
Expand Down Expand Up @@ -142,6 +146,17 @@ function Inscription() {
<div className="inscription">Inscription</div>
</button>
</div>
{showModal && (
<div className="modal">
<div className="modal-content">
<p>Votre inscription a été effectuée avec succès</p>

<button onClick={toggleModal} type="button">
<NavLink to="/Connection">Fermer</NavLink>
</button>
</div>
</div>
)}
</div>
</div>
</div>
Expand Down
40 changes: 40 additions & 0 deletions frontend/src/sass/_inscription.scss
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,44 @@
color: var(--background-color);
font-weight: var(--font-weight-semi-bold);
}
.modal {
display: flex;
justify-content: center;
align-items: center;
border: solid 2px var(--secondary-font-color);
border-radius: 10px;
position: fixed;
top: 50%;
left: 50%;
width: 35vw;
height: 25vh;
background-color: var(--background-color);
z-index: 1000;
transform: translate(-50%, -50%);

.modal-content {
padding: 10px;
text-align: center;

button {
padding: 8px 20px;
border: none;
border-radius: 4px;
background-color: rgba(238, 226, 226, 0.1);
font-size: 14px;
cursor: pointer;
transition: background-color 0.3s ease;
margin: 15px;

&:hover {
background-color: #ff509a;
}

a {
text-decoration: none;
color: white;
}
}
}
}
}