MainNav.js 1.53 KB
Newer Older
1
import React from 'react';
Kim, Subin's avatar
Kim, Subin committed
2
import { Navbar, Nav } from 'react-bootstrap';
kusang96's avatar
kusang96 committed
3
import { handleLogout, isAuthenticated, isAdmin } from '../utils/auth';
Kim, Subin's avatar
Kim, Subin committed
4
5

function MainNav() {
이재연's avatar
이재연 committed
6
    const user = isAuthenticated()
kusang96's avatar
kusang96 committed
7
    const admin = isAdmin()
Kim, Subin's avatar
Kim, Subin committed
8
9

    return (
Kim, Subin's avatar
Kim, Subin committed
10
11
        <Navbar sticky="top" style={{ background: "#CDC5C2" }}>
            <Navbar.Brand href="/home" className="text-light">
박상호's avatar
good    
박상호 committed
12
                <img alt="로고" src="/icon/footprint.svg" width="18" height="18" />
Kim, Subin's avatar
Kim, Subin committed
13
14
                {' '}KU#
            </Navbar.Brand>
박상호's avatar
good    
박상호 committed
15
16
17
18
19
20
21
22
23
24
            <Nav className="ml-auto d-flex align-items-center">
                {user ?
                    <>
                        <Nav.Link className="text-light" onClick={() => handleLogout()}>Logout</Nav.Link>
                        <Nav.Link className="text-light" href="/account"> Mypage </Nav.Link>
                        <Nav.Link href="/shoppingcart">
                            <img alt="카트" src="/icon/cart.svg" width="30" height="30" />
                        </Nav.Link>
                    </>
                    : ( 
이재연's avatar
이재연 committed
25
26
27
28
29
                        <>
                            <Nav.Link className="text-light" href='/login'>Login</Nav.Link>
                            <Nav.Link className="text-light" href='/signup'>Sign Up</Nav.Link>
                        </>
                    )}
kusang96's avatar
kusang96 committed
30
                {admin ? <Nav.Link href="/admin">
31
                    <img alt="관리자" src="/icon/option.svg" width="30" height="30" />
kusang96's avatar
kusang96 committed
32
                </Nav.Link> : ''}
Kim, Subin's avatar
Kim, Subin committed
33
34
            </Nav>
        </Navbar>
Kim, Subin's avatar
Kim, Subin committed
35
36
37
38
    )
}

export default MainNav