From f197c05b0c81e7f176b43166067fbe5748f84bb5 Mon Sep 17 00:00:00 2001 From: MarcEricMartel <74071476+MarcEricMartel@users.noreply.github.com> Date: Sun, 6 Nov 2022 06:48:07 -0800 Subject: [PATCH] !!!! --- .../src/components/Topbar.js | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/GrossesMitaines/grosses-mitaines-ui/src/components/Topbar.js b/GrossesMitaines/grosses-mitaines-ui/src/components/Topbar.js index e725000..92a4486 100644 --- a/GrossesMitaines/grosses-mitaines-ui/src/components/Topbar.js +++ b/GrossesMitaines/grosses-mitaines-ui/src/components/Topbar.js @@ -2,18 +2,28 @@ import React, { useEffect, useState } from "react"; import Container from 'react-bootstrap/Container'; import Nav from 'react-bootstrap/Nav'; import Navbar from 'react-bootstrap/Navbar'; +import Button from 'react-bootstrap/Button'; import { Link } from "react-router-dom"; import Dropdown from "react-bootstrap/Dropdown"; import { useCookies } from "react-cookie"; const Topbar = () => { - const [cookies, setCookie] = useCookies(['name']); - var user = cookies.GMGM ?? null; + const [cookies, setCookie, removeCookie] = useCookies(['name']); + const [user, setLogin] = useState(null); useEffect(() => { - if (cookies.GMGM !== user) - user = cookies.GMGM; + setLogin(cookies.GMGM ?? null); }); + function logOut() { + const response = fetch(`https://localhost:7292/api/Logout`, { + method: 'POST', + credentials: 'include' + }) + + removeCookie("GMGM"); + setLogin(null); // Y U NO WORK?!? + } + return ( @@ -70,9 +80,9 @@ const Topbar = () => { - + {user.role === "Administrateur" &&