Merge branch 'react-version' of https://github.com/MarcEricMartel/420-5DW-HY-TP into react-version

This commit is contained in:
Victor Turgeon 2022-10-30 12:43:20 -07:00
commit 52a890fd6e
4 changed files with 74 additions and 2 deletions

View File

@ -7,9 +7,9 @@ import ContactUs from "../pages/ContactUs";
import Morceaux from "../pages/Morceaux"; import Morceaux from "../pages/Morceaux";
import MorceauDetail from "../pages/MorceauDetail"; import MorceauDetail from "../pages/MorceauDetail";
import Inventaire from "../pages/Inventaire"; import Inventaire from "../pages/Inventaire";
import Login from "../pages/Login";
import Logout from "../pages/Logout";
const App = () => { const App = () => {
return ( return (
<BrowserRouter> <BrowserRouter>
<Routes> <Routes>
@ -21,6 +21,8 @@ const App = () => {
<Route path="privacy" element={<Privacy/>}/> <Route path="privacy" element={<Privacy/>}/>
<Route path="morceaux/:id" element={<MorceauDetail/>}/> <Route path="morceaux/:id" element={<MorceauDetail/>}/>
<Route path="inventaire" element={<Inventaire/>}/> <Route path="inventaire" element={<Inventaire/>}/>
<Route path="login" element={<Login/>}/>
<Route path="logout" element={<Logout/>}/>
</Route> </Route>
</Routes> </Routes>
</BrowserRouter> </BrowserRouter>

View File

@ -31,6 +31,12 @@ const Topbar = () => {
<Link className="nav-link" to="/privacy" > <Link className="nav-link" to="/privacy" >
Vie privée Vie privée
</Link> </Link>
<Link className="nav-link" to="/login" >
Connexion
</Link>
<Link className="nav-link" to="/logout" >
Déconnexion
</Link>
<Dropdown className="dropdown-gestion-container"> <Dropdown className="dropdown-gestion-container">
<Dropdown.Toggle className="dropdown-gestion" > <Dropdown.Toggle className="dropdown-gestion" >
Gestion Gestion

View File

@ -0,0 +1,49 @@
import { useState } from "react";
import { Button } from "react-bootstrap";
const Login = () => {
const [username, setUsername] = useState("");
const [password, setPassword] = useState("");
const handleLogin = async (e) => {
e.preventDefault();
const response = await fetch(`https://localhost:7292/api/Login?rememberme=true`, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({ username, password })
})
// Partie de display d'erreur ou de redirection (faudrait checker pour se faire un state de connexion).
}
return (
<div className="inventaire-form-container">
<form className="form-horizontal" onSubmit={handleLogin}>
<h4 className="text-center">Connexion</h4>
<div className="form-group">
<label>Nom Utilisateur: </label>
<input className="form-control form-input" type='text'
placeholder="Nom de l'utilisateur..."
value={username}
onChange={(e) => setUsername(e.target.value)} />
</div>
<div className="form-group">
<label>Mot de passe: </label>
<input type='password' className="form-control form-input"
placeholder="Mot de passe..."
value={password}
onChange={(e) => setPassword(e.target.value)} />
</div>
<Button className="btn-primary btn-ajouter-morceau" type="submit" >Connexion</Button>
</form>
</div>
)
}
export default Login;

View File

@ -0,0 +1,15 @@
const Logout = () => {
const response = fetch(`https://localhost:7292/api/Logout`, {
method: 'POST',
})
return (
<div className="inventaire-form-container">
<h3 className="text-center">Vous n'êtes plus connecté!</h3>
<h5 className="text-center">Faites le party ou quelque-chose...</h5>
</div>
)
}
export default Logout;