Menu.js 1.87 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
7
8
9
10
11
    background-color: #7B031D;
    max-height : 50px;

    a {
        color: #ffffff;
    }
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()
Ha YeaJin's avatar
Ha YeaJin committed
16

CHAERIN KIM's avatar
CHAERIN KIM committed
17
18
19
20
    if (state) return <Redirect to="/" />;

    function logout() {
        localStorage.removeItem('token');
Ha YeaJin's avatar
Ha YeaJin committed
21
        alert("로그인 화면으로 이동합니다.");
CHAERIN KIM's avatar
CHAERIN KIM committed
22
23
24
        setState(true);
    }

Ha YeaJin's avatar
pages    
Ha YeaJin committed
25
26
    return (
        <Nav className="navbar sticky-top navbar-expand-md">
Ha YeaJin's avatar
Ha YeaJin committed
27
            <a class="navbar-brand" href="#">대관 서비스</a>
Ha YeaJin's avatar
pages    
Ha YeaJin committed
28
29
30
            <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
31
            <div className="collapse navbar-collapse justify-content-between" id="collapsibleNavbar">
Ha YeaJin's avatar
pages    
Ha YeaJin committed
32
                <ul className="navbar-nav">
Ha YeaJin's avatar
Ha YeaJin committed
33
34
35
                    <li className="nav-item">
                        <Link to="/notice" className="nav-link">공지사항</Link>
                    </li>
Ha YeaJin's avatar
pages    
Ha YeaJin committed
36
37
38
39
40
41
42
43
44
45
                    <li className="nav-item">
                        <Link to="/home" className="nav-link">대관 현황</Link>
                    </li>
                    <li className="nav-item">
                        <Link to="/apply" className="nav-link">대관 신청</Link>
                    </li>
                    <li className="nav-item">
                        <Link to="/check" className="nav-link">대관 확인/취소</Link>
                    </li>
                </ul>
CHAERIN KIM's avatar
CHAERIN KIM committed
46
                <div>
Ha YeaJin's avatar
Ha YeaJin committed
47
                    <div></div>
CHAERIN KIM's avatar
CHAERIN KIM committed
48
49
                    <button onClick={logout} type="button">로그아웃</button>
                </div>
Ha YeaJin's avatar
pages    
Ha YeaJin committed
50
51
52
53
54
55
            </div>
        </Nav>
    )
}

export default Menu