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

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

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

export default MainNav