Merge branch 'react-version' of https://github.com/MarcEricMartel/420-5DW-HY-TP into react-version
This commit is contained in:
commit
52a890fd6e
@ -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>
|
||||||
|
@ -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
|
||||||
|
49
GrossesMitaines/grosses-mitaines-ui/src/pages/Login.js
Normal file
49
GrossesMitaines/grosses-mitaines-ui/src/pages/Login.js
Normal 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;
|
15
GrossesMitaines/grosses-mitaines-ui/src/pages/Logout.js
Normal file
15
GrossesMitaines/grosses-mitaines-ui/src/pages/Logout.js
Normal 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;
|
Loading…
Reference in New Issue
Block a user