Menu.js 2.57 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, NavLink } 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
9
10
11

    a {
        color : white;
    }
Ha YeaJin's avatar
pages    
Ha YeaJin committed
12
13
14
`

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

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

Ha YeaJin's avatar
Ha YeaJin committed
24
    if (state) return <Redirect to="/" />
Ha YeaJin's avatar
pages    
Ha YeaJin committed
25
    return (
Ha YeaJin's avatar
Ha YeaJin committed
26
27
28
29
30
        <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">
Ha YeaJin's avatar
Ha YeaJin committed
31
32
33
34
                    <NavLink as={Link} to="/notice">공지사항</NavLink>
                    <NavLink as={Link} to="/home">대관 현황</NavLink>

                    <NavLink as={Link} to={{
Ha YeaJin's avatar
Ha YeaJin committed
35
36
                        pathname: `/apply/${localStorage.getItem('_id')}`,
                        state: { id: localStorage.getItem('_id') },
Ha YeaJin's avatar
Ha YeaJin committed
37
38
39
                    }} className="nav-link">대관 신청</NavLink>

                    <NavLink as={Link} to={{
Ha YeaJin's avatar
Ha YeaJin committed
40
41
42
                        pathname: `/check/${localStorage.getItem('_id')}`,
                        state: { id: localStorage.getItem('_id') },
                    }} className="nav-link">
Ha YeaJin's avatar
Ha YeaJin committed
43
44
45
                        대관 확인/취소</NavLink>

                    <NavLink as={Link} to={{
Ha YeaJin's avatar
Ha YeaJin committed
46
47
48
                        pathname: `/acheck/${localStorage.getItem('_id')}`,
                        state: { id: localStorage.getItem('_id') },
                    }} className="nav-link">
Ha YeaJin's avatar
Ha YeaJin committed
49
50
51
52
53
54
55
                        대관 확인/취소(관리자)</NavLink>
                </Nav>
                <Nav >
                    <NavLink>
                        <small className="d-flex flex-row justify-content-end">
                            <div className="text-white text-right font-weight-light pr-2">{name}</div>
                            <NavLink className="p-0" as={Link} to={{
Ha YeaJin's avatar
Ha YeaJin committed
56
57
                                pathname: `/change/${localStorage.getItem('_id')}`,
                                state: { id: localStorage.getItem('_id') },
Ha YeaJin's avatar
Ha YeaJin committed
58
59
                            }}>  비밀번호 변경 </NavLink> / <NavLink className="p-0" onClick={logout} > 로그아웃</NavLink></small>
                    </NavLink>
Ha YeaJin's avatar
Ha YeaJin committed
60
61
62
                </Nav>
            </Navbar.Collapse>
        </MENU >
Ha YeaJin's avatar
pages    
Ha YeaJin committed
63
64
65
66
    )
}

export default Menu