!!!!
This commit is contained in:
parent
10254a6439
commit
f197c05b0c
@ -2,18 +2,28 @@ import React, { useEffect, useState } from "react";
|
|||||||
import Container from 'react-bootstrap/Container';
|
import Container from 'react-bootstrap/Container';
|
||||||
import Nav from 'react-bootstrap/Nav';
|
import Nav from 'react-bootstrap/Nav';
|
||||||
import Navbar from 'react-bootstrap/Navbar';
|
import Navbar from 'react-bootstrap/Navbar';
|
||||||
|
import Button from 'react-bootstrap/Button';
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import Dropdown from "react-bootstrap/Dropdown";
|
import Dropdown from "react-bootstrap/Dropdown";
|
||||||
import { useCookies } from "react-cookie";
|
import { useCookies } from "react-cookie";
|
||||||
|
|
||||||
const Topbar = () => {
|
const Topbar = () => {
|
||||||
const [cookies, setCookie] = useCookies(['name']);
|
const [cookies, setCookie, removeCookie] = useCookies(['name']);
|
||||||
var user = cookies.GMGM ?? null;
|
const [user, setLogin] = useState(null);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (cookies.GMGM !== user)
|
setLogin(cookies.GMGM ?? null);
|
||||||
user = cookies.GMGM;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function logOut() {
|
||||||
|
const response = fetch(`https://localhost:7292/api/Logout`, {
|
||||||
|
method: 'POST',
|
||||||
|
credentials: 'include'
|
||||||
|
})
|
||||||
|
|
||||||
|
removeCookie("GMGM");
|
||||||
|
setLogin(null); // Y U NO WORK?!?
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Navbar expand="sm" className="topbar-container">
|
<Navbar expand="sm" className="topbar-container">
|
||||||
<Container>
|
<Container>
|
||||||
@ -70,9 +80,9 @@ const Topbar = () => {
|
|||||||
</Link>
|
</Link>
|
||||||
</Dropdown.Item>
|
</Dropdown.Item>
|
||||||
<Dropdown.Item>
|
<Dropdown.Item>
|
||||||
<Link className="nav-link" to="/logout" >
|
<Button className="nav-link" onClick={() => logOut()}>
|
||||||
Déconnexion
|
Déconnexion
|
||||||
</Link>
|
</Button>
|
||||||
</Dropdown.Item>
|
</Dropdown.Item>
|
||||||
{user.role === "Administrateur" &&
|
{user.role === "Administrateur" &&
|
||||||
<Container>
|
<Container>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user