-
Notifications
You must be signed in to change notification settings - Fork 91
Add logout button - closes #1653 #1686
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
base: master
Are you sure you want to change the base?
Changes from 3 commits
e939f7d
8e3a16c
0543bce
c0458d3
6ea82d8
cdc9f22
219af29
fbd9f02
9501855
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,36 +1,51 @@ | ||
| import React from "react"; | ||
| import { Link } from "react-router-dom"; | ||
| import React, {useState, useEffect} from "react"; | ||
| import { Link, useLocation } from "react-router-dom"; | ||
| import Logo from "../Logo"; | ||
| import { isLoggedIn, oeciLogout } from "../../service/cookie-service"; | ||
|
|
||
| export default class Header extends React.Component { | ||
| public render() { | ||
| return ( | ||
| <div className="bg-white shadow"> | ||
| <nav | ||
| className="mw8 relative center flex flex-wrap justify-between pa3" | ||
| aria-label="Primary" | ||
| > | ||
| <div className="logo mb4 mb0-ns"> | ||
| <Link to="/" aria-label="Home"> | ||
| <Logo /> | ||
| </Link> | ||
| </div> | ||
| <div className="mt5 mt2-ns"> | ||
| <Link | ||
| to="/manual" | ||
| className="link hover-blue f5 fw6 pv2 ph0 ph3-ns mr4-ns" | ||
| > | ||
| Manual | ||
| </Link> | ||
| <Link | ||
| to="/record-search" | ||
| className="absolute top-1 right-1 static-ns bg-blue white bg-animate hover-bg-dark-blue f5 fw6 br2 pv2 ph3" | ||
|
|
||
| export default function Header (){ | ||
| const [loggedIn, setLoggedIn] = useState(isLoggedIn()); | ||
| const location = useLocation(); | ||
|
|
||
| useEffect(() => { | ||
| setLoggedIn(isLoggedIn()); | ||
| }, [location]); | ||
|
|
||
|
||
| return ( | ||
| <div className="bg-white shadow"> | ||
| <nav | ||
| className="mw8 relative center flex flex-wrap justify-between pa3" | ||
| aria-label="Primary" | ||
| > | ||
| <div className="logo mb4 mb0-ns"> | ||
| <Link to="/" aria-label="Home"> | ||
| <Logo /> | ||
| </Link> | ||
| </div> | ||
| <div className="mt5 mt2-ns"> | ||
| <Link | ||
| to="/manual" | ||
| className="link hover-blue f5 fw6 pv2 ph0 ph3-ns mr4-ns" | ||
| > | ||
| Manual | ||
| </Link> | ||
| <Link | ||
| to="/record-search" | ||
| className="absolute top-1 right-1 static-ns bg-blue white bg-animate hover-bg-dark-blue f5 fw6 br2 pv2 ph3" | ||
| > | ||
| Search | ||
| </Link> | ||
| {loggedIn && ( | ||
| <button | ||
| onClick={oeciLogout} | ||
| className="absolute top-1 left-2 static-ns bg-white f5 fw6 br2 ba b--blue blue link hover-dark-blue pv2 ph3 ml2" | ||
| > | ||
| Search | ||
| </Link> | ||
| </div> | ||
| </nav> | ||
| </div> | ||
| ); | ||
| } | ||
| Log Out | ||
| </button> | ||
| )} | ||
| </div> | ||
| </nav> | ||
| </div> | ||
| ); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.