Menu.js 1 KB
Newer Older
JeongYeonwoo's avatar
JeongYeonwoo committed
1
import React, { useState, useEffect } from 'react'
Choi Ga Young's avatar
Choi Ga Young committed
2
import { Navbar, Nav, Button } from 'react-bootstrap';
우지원's avatar
우지원 committed
3
import { Link } from 'react-router-dom';
4
import { handleLogout } from '../utils/auth';
JeongYeonwoo's avatar
JeongYeonwoo committed
5
import axios from 'axios'
Choi Ga Young's avatar
Choi Ga Young committed
6

7

Choi Ga Young's avatar
Choi Ga Young committed
8
function Menu() {
9

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

  return (
    <Navbar bg="dark" variant="dark">
      <Navbar.Brand href="/home">YDK Messenger</Navbar.Brand>
우지원's avatar
우지원 committed
15
16
      {name ?
        <>
우지원's avatar
수정    
우지원 committed
17
          <div className='ml-1 mr-2' style={{ color: 'white' }}>{name} 환영합니다</div>
우지원's avatar
우지원 committed
18
          <Nav className="mr-auto">
우지원's avatar
수정    
우지원 committed
19
            {/* <Nav.Link href="/home">Home</Nav.Link> */}
우지원's avatar
우지원 committed
20
21
22
23
24
25
26
27
            <Nav.Link href="/profile">Profile</Nav.Link>
          </Nav>
          <Button className="ml-auto" onClick={() => handleLogout()} variant="light" className="ml-3">Logout</Button>
        </>
        : <Nav className="ml-auto">
          <Nav.Link href='/login'>로그인</Nav.Link>
          <Nav.Link href='/signup'>회원가입</Nav.Link>
        </Nav>}
Choi Ga Young's avatar
Choi Ga Young committed
28
29
30
31
32
    </Navbar>
  )
}

export default Menu