SubNav.js 912 Bytes
Newer Older
한규민's avatar
한규민 committed
1
2
import { Link } from "react-router-dom";
import { useAuth } from "../../context/auth_context.js"
Jiwon Yoon's avatar
Jiwon Yoon committed
3
const SubNav = () => {
한규민's avatar
한규민 committed
4
    const { user, logout } = useAuth();
한규민's avatar
context    
한규민 committed
5

한규민's avatar
한규민 committed
6
7
8
    return (
        <>  {(user) ?
            <nav className="nav justify-content-end py-1">
Jiwon Yoon's avatar
app.js    
Jiwon Yoon committed
9
10
11
                {(user.role === "member")
                    ? <Link className="nav-link text-white" to="/mypage">마이페이지</Link>
                    : <Link className="nav-link text-white" to="/admin">관리자페이지</Link>}
한규민's avatar
한규민 committed
12
13
14
15
16
                <Link className="nav-link text-white" to="/" onClick={logout}>로그아웃 </Link>
            </nav> :
            <nav className="nav justify-content-end py-1">
                <Link className="nav-link text-white" to="/login">로그인</Link>
                <Link className="nav-link text-white" to="/signup" >회원가입</Link>
한규민's avatar
context    
한규민 committed
17
            </nav>
한규민's avatar
한규민 committed
18
19
20
        }
        </>
    )
Jiwon Yoon's avatar
Jiwon Yoon committed
21
22
}
export default SubNav