MainNav.js 1.44 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">
12
                <img alt="로고" src="/icon/footprint.svg" width="24" height="24" />
Kim, Subin's avatar
Kim, Subin committed
13
14
                {' '}KU#
            </Navbar.Brand>
Jiwon Yoon's avatar
asdf    
Jiwon Yoon committed
15
            <Nav className="ml-auto">
박상호's avatar
박상호 committed
16
                {user ? <> <Nav.Link className="text-light" onClick={() => handleLogout()}>Logout</Nav.Link>
kusang96's avatar
kusang96 committed
17
18
19
20
                    <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
21
                </>
이재연's avatar
이재연 committed
22
23
24
25
26
27
                    : (
                        <>
                            <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
28
                {admin ? <Nav.Link href="/admin">
29
                    <img alt="관리자" src="/icon/option.svg" width="30" height="30" />
kusang96's avatar
kusang96 committed
30
                </Nav.Link> : ''}
Kim, Subin's avatar
Kim, Subin committed
31
32
            </Nav>
        </Navbar>
Kim, Subin's avatar
Kim, Subin committed
33
34
35
36
    )
}

export default MainNav