Menu.js 3.12 KB
Newer Older
Ha YeaJin's avatar
pages    
Ha YeaJin committed
1
import React, { useState, useEffect } from 'react';
CHAERIN KIM's avatar
CHAERIN KIM committed
2
import { Link, Redirect } from 'react-router-dom';
Ha YeaJin's avatar
pages    
Ha YeaJin committed
3
4
5
import styled from 'styled-components';

const Nav = styled.nav`
Ha YeaJin's avatar
Ha YeaJin committed
6
    background-color: #7B031D;
7
    height: 6vh;
Ha YeaJin's avatar
Ha YeaJin committed
8
9
10
11

    a {
        color: #ffffff;
    }
12
13
14
15

    & .logoutBtn:hover {
        text-decoration: underline;
    }
Ha YeaJin's avatar
pages    
Ha YeaJin committed
16
17
18
`

function Menu() {
CHAERIN KIM's avatar
CHAERIN KIM committed
19
    const [state, setState] = useState()
CHAERIN KIM's avatar
CHAERIN KIM committed
20
    const name = localStorage.getItem('name');
Ha YeaJin's avatar
Ha YeaJin committed
21

CHAERIN KIM's avatar
CHAERIN KIM committed
22
23
24
    if (state) return <Redirect to="/" />;

    function logout() {
CHAERIN KIM's avatar
CHAERIN KIM committed
25
        localStorage.clear();
CHAERIN KIM's avatar
CHAERIN KIM committed
26
        alert("로그아웃 되었습니다.");
CHAERIN KIM's avatar
CHAERIN KIM committed
27
28
29
        setState(true);
    }

Ha YeaJin's avatar
pages    
Ha YeaJin committed
30
31
    return (
        <Nav className="navbar sticky-top navbar-expand-md">
Ha YeaJin's avatar
Ha YeaJin committed
32
            <a class="navbar-brand" href="#">대관 서비스</a>
Ha YeaJin's avatar
pages    
Ha YeaJin committed
33
34
35
            <button className="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar" aria-controls="collapsibleNavbar">
                <span className="navbar-toggler-icon"></span>
            </button>
CHAERIN KIM's avatar
CHAERIN KIM committed
36
            <div className="collapse navbar-collapse justify-content-between" id="collapsibleNavbar">
Ha YeaJin's avatar
pages    
Ha YeaJin committed
37
                <ul className="navbar-nav">
Ha YeaJin's avatar
Ha YeaJin committed
38
39
40
                    <li className="nav-item">
                        <Link to="/notice" className="nav-link">공지사항</Link>
                    </li>
Ha YeaJin's avatar
pages    
Ha YeaJin committed
41
42
43
44
                    <li className="nav-item">
                        <Link to="/home" className="nav-link">대관 현황</Link>
                    </li>
                    <li className="nav-item">
CHAERIN KIM's avatar
CHAERIN KIM committed
45
46
47
48
                        <Link to={{
                            pathname: `/apply/${localStorage.getItem('_id')}`,
                            state: { id: localStorage.getItem('_id') },
                        }} className="nav-link">대관 신청</Link>
Ha YeaJin's avatar
pages    
Ha YeaJin committed
49
50
                    </li>
                    <li className="nav-item">
51
52
53
54
55
                        <Link to={{
                            pathname: `/check/${localStorage.getItem('_id')}`,
                            state: { id: localStorage.getItem('_id') },
                        }} className="nav-link">
                            대관 확인/취소</Link>
Ha YeaJin's avatar
pages    
Ha YeaJin committed
56
                    </li>
57
58
59
60
61
62
63
                    <li className="nav-item">
                        <Link to={{
                            pathname: `/acheck/${localStorage.getItem('_id')}`,
                            state: { id: localStorage.getItem('_id') },
                        }} className="nav-link">
                            대관 확인/취소(관리자)</Link>
                    </li>
Ha YeaJin's avatar
pages    
Ha YeaJin committed
64
                </ul>
65
66
67
68
69
70
71
                <div className="h-100 mr-3">
                    <div className="text-white text-right font-weight-light"><small>{name} 안녕하세요</small></div>
                    <div className="text-white text-right font-weight-light"><small>
                        <Link to={{
                            pathname: `/change/${localStorage.getItem('_id')}`,
                            state: { id: localStorage.getItem('_id') },
                        }}>비밀번호 변경</Link> / <span className="logoutBtn" onClick={logout} >로그아웃</span></small></div>
CHAERIN KIM's avatar
CHAERIN KIM committed
72
                </div>
Ha YeaJin's avatar
pages    
Ha YeaJin committed
73
74
75
76
77
78
            </div>
        </Nav>
    )
}

export default Menu