MainNav.js 1.77 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
            <Nav className="ml-auto d-flex align-items-center">
                {user ?
                    <>
                        <Nav.Link className="text-light" onClick={() => handleLogout()}>Logout</Nav.Link>
박상호's avatar
good    
박상호 committed
19
20
21
                        {admin ?
                            ''
                            : (
박상호's avatar
css    
박상호 committed
22
23
24
25
26
27
28
                                <>
                                    <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
good    
박상호 committed
29
                            )}
박상호's avatar
good    
박상호 committed
30
                    </>
kusang96's avatar
kusang96 committed
31
                    : (
이재연's avatar
이재연 committed
32
33
34
35
36
                        <>
                            <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
37
                {admin ? <Nav.Link href="/admin">
38
                    <img alt="관리자" src="/icon/option.svg" width="30" height="30" />
kusang96's avatar
kusang96 committed
39
                </Nav.Link> : ''}
Kim, Subin's avatar
Kim, Subin committed
40
41
            </Nav>
        </Navbar>
Kim, Subin's avatar
Kim, Subin committed
42
43
44
45
    )
}

export default MainNav