Menu.js 1.68 KB
Newer Older
Soo Hyun Kim's avatar
Soo Hyun Kim committed
1
import React, { useState } from 'react'
2
import { Navbar, Nav } from 'react-bootstrap';
3
import { handleLogout } from '../utils/auth';
Soo Hyun Kim's avatar
Soo Hyun Kim committed
4
5
6
import styled from 'styled-components';
import { BsPeopleCircle  } from "react-icons/bs";
import { AiOutlineLogout } from "react-icons/ai";
7

Choi Ga Young's avatar
Choi Ga Young committed
8
function Menu() {
Soo Hyun Kim's avatar
Soo Hyun Kim committed
9
  const [showIcon, setShowIcon] = useState(false);
10

Choi Ga Young's avatar
aa    
Choi Ga Young committed
11
  const name = sessionStorage.getItem('name');
Choi Ga Young's avatar
Choi Ga Young committed
12

Soo Hyun Kim's avatar
Soo Hyun Kim committed
13
  console.log('showIcon', showIcon)
Choi Ga Young's avatar
Choi Ga Young committed
14
  return (
Soo Hyun Kim's avatar
Soo Hyun Kim committed
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
    <MenuDiv setShowIcon={setShowIcon}>
      <Navbar style={{ backgroundColor: "#61477a", heigth: "100%" }} variant="dark">
        <div className="container-fluid">
          <Navbar.Brand className="navbar-brand" href="/home">YDK Messenger</Navbar.Brand>
          {name ?
            <>
              <Nav className="nav navbar-nav mr-auto" style={{ color: 'white' }}>
                <Nav.Item className="mt-2 mr-4">{name} 환영합니다</Nav.Item>
                { showIcon ?
                <a href="/profile"><BsPeopleCircle size="15" color="#FFFFFF"/></a>
                :<Nav.Link href="/profile">Profile</Nav.Link>}
                { showIcon ?
                <a href="/login" onClick={() => handleLogout()}><AiOutlineLogout size="15" color="#FFFFFF"/></a>
                :<Nav.Link onClick={() => handleLogout()} href="/login">logout</Nav.Link>}
              </Nav>
            </>
            : <>
              <Nav className="nav navbar-nav">
                <Nav.Link href="/login">Login</Nav.Link>
                <Nav.Link href="/signup">Signup</Nav.Link>
              </Nav>
            </>}
        </div>
      </Navbar>
    </MenuDiv>
Choi Ga Young's avatar
Choi Ga Young committed
40
41
42
  )
}

Soo Hyun Kim's avatar
Soo Hyun Kim committed
43
44
45
46
47
48
const MenuDiv = styled.div`
@media (max-width: 500px) {
    display: 'none';
   }
`

우지원's avatar
우지원 committed
49

Choi Ga Young's avatar
Choi Ga Young committed
50
export default Menu