Menu.js 4.86 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
import styled from 'styled-components';
Ha YeaJin's avatar
Ha YeaJin committed
4
import { Navbar, Nav, NavDropdown } from 'react-bootstrap';
Ha YeaJin's avatar
pages    
Ha YeaJin committed
5

Ha YeaJin's avatar
Ha YeaJin committed
6
const MENU = styled(Navbar)`
Ha YeaJin's avatar
Ha YeaJin committed
7
    background-color: #7B031D;
Ha YeaJin's avatar
Ha YeaJin committed
8
    
Ha YeaJin's avatar
pages    
Ha YeaJin committed
9
10
11
`

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

CHAERIN KIM's avatar
CHAERIN KIM committed
15
    function logout() {
CHAERIN KIM's avatar
CHAERIN KIM committed
16
        localStorage.clear();
CHAERIN KIM's avatar
CHAERIN KIM committed
17
        alert("로그아웃 되었습니다.");
CHAERIN KIM's avatar
CHAERIN KIM committed
18
19
20
        setState(true);
    }

Ha YeaJin's avatar
Ha YeaJin committed
21
    if (state) return <Redirect to="/" />
Ha YeaJin's avatar
pages    
Ha YeaJin committed
22
    return (
Ha YeaJin's avatar
Ha YeaJin committed
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
        <MENU expand="md" variant="dark">
            <Navbar.Brand href="#">대관 서비스</Navbar.Brand>
            <Navbar.Toggle aria-controls="basic-navbar-nav" />
            <Navbar.Collapse id="basic-navbar-nav">
                <Nav className="mr-auto">
                    <Nav.Link><Link to="/notice">공지사항</Link></Nav.Link>
                    <Nav.Link><Link to="/home">대관 현황</Link></Nav.Link>
                    <Nav.Link><Link to={{
                        pathname: `/apply/${localStorage.getItem('_id')}`,
                        state: { id: localStorage.getItem('_id') },
                    }} className="nav-link">대관 신청</Link></Nav.Link>
                    <Nav.Link><Link to={{
                        pathname: `/check/${localStorage.getItem('_id')}`,
                        state: { id: localStorage.getItem('_id') },
                    }} className="nav-link">
                        대관 확인/취소</Link></Nav.Link>
                    <Nav.Link><Link to={{
                        pathname: `/acheck/${localStorage.getItem('_id')}`,
                        state: { id: localStorage.getItem('_id') },
                    }} className="nav-link">
                        대관 확인/취소(관리자)</Link></Nav.Link>
                    <Nav.Link>
                        <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>
                    </Nav.Link>
                </Nav>

            </Navbar.Collapse>

            {/* <button className="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar" aria-controls="collapsibleNavbar">
Ha YeaJin's avatar
pages    
Ha YeaJin committed
58
                <span className="navbar-toggler-icon"></span>
Ha YeaJin's avatar
Ha YeaJin committed
59
60
            </button> */}
            {/* <div className="collapse navbar-collapse justify-content-between" id="collapsibleNavbar">
Ha YeaJin's avatar
pages    
Ha YeaJin committed
61
                <ul className="navbar-nav">
Ha YeaJin's avatar
Ha YeaJin committed
62
63
64
                    <li className="nav-item">
                        <Link to="/notice" className="nav-link">공지사항</Link>
                    </li>
Ha YeaJin's avatar
pages    
Ha YeaJin committed
65
66
67
68
                    <li className="nav-item">
                        <Link to="/home" className="nav-link">대관 현황</Link>
                    </li>
                    <li className="nav-item">
CHAERIN KIM's avatar
CHAERIN KIM committed
69
70
71
72
                        <Link to={{
                            pathname: `/apply/${localStorage.getItem('_id')}`,
                            state: { id: localStorage.getItem('_id') },
                        }} className="nav-link">대관 신청</Link>
Ha YeaJin's avatar
pages    
Ha YeaJin committed
73
74
                    </li>
                    <li className="nav-item">
75
76
77
78
79
                        <Link to={{
                            pathname: `/check/${localStorage.getItem('_id')}`,
                            state: { id: localStorage.getItem('_id') },
                        }} className="nav-link">
                            대관 확인/취소</Link>
Ha YeaJin's avatar
pages    
Ha YeaJin committed
80
                    </li>
81
82
83
84
85
86
87
                    <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
88
                </ul>
89
90
91
92
93
94
95
                <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
96
                </div>
Ha YeaJin's avatar
Ha YeaJin committed
97
98
            </div> */}
        </MENU >
Ha YeaJin's avatar
pages    
Ha YeaJin committed
99
100
101
102
    )
}

export default Menu