-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnavbar.js
32 lines (31 loc) · 1.01 KB
/
navbar.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import React from "react";
import { useRouter } from "next/router";
import styles from "./styles/Home.module.css";
import { Button, Icon } from "semantic-ui-react";
import { useState, useEffect } from "react";
export default function Navbar() {
const rout = useRouter();
const [login, setLogin] = useState(false);
useEffect(() => {
setLogin(localStorage.getItem("accessToken") != undefined ? true : false);
}, []);
const handleLogin = () => {
localStorage.removeItem("updateChange");
localStorage.removeItem("accessToken");
setLogin((prevState) => !prevState);
rout.replace('/login');
};
return (
<div className={styles.navbar}>
<a onClick={() => rout.push("/")} className={styles.navlogo}>
MAYUR
</a>
<Button animated style={{ margin: "0" }} onClick={handleLogin}>
<Button.Content visible>{login ? "Logout" : "Login"}</Button.Content>
<Button.Content hidden>
<Icon name="arrow right" />
</Button.Content>
</Button>
</div>
);
}