|
1 | 1 | 'use client'; |
2 | 2 |
|
3 | | -import React from 'react'; |
| 3 | +import React, {useState} from 'react'; |
4 | 4 | import Link from 'next/link'; |
5 | | -import { useAuth } from '@/hooks/useAuth'; |
6 | | -import { useRouter } from 'next/navigation'; |
7 | | - |
8 | | -const NAVIGATION_ITEMS = [ |
9 | | - { href: '/recommendations', label: '직무 추천' }, |
10 | | - { href: '/jobs', label: '직무 리스트' }, |
11 | | - { href: '/roadmap', label: '직무 로드맵' } |
12 | | -]; |
| 5 | +import Image from 'next/image'; |
| 6 | +import {useAuth} from '@/hooks/useAuth'; |
| 7 | +import {useRouter} from 'next/navigation'; |
13 | 8 |
|
14 | 9 | export const Header: React.FC = () => { |
15 | | - const { user, isLoggedIn, logout, isLoading } = useAuth(); |
| 10 | + const {isLoggedIn, user, logout} = useAuth(); |
| 11 | + const [showUserMenu, setShowUserMenu] = useState(false); |
16 | 12 | const router = useRouter(); |
17 | 13 |
|
18 | | - const handleLogoClick = () => { |
19 | | - router.push('/'); |
20 | | - }; |
21 | | - |
22 | 14 | const handleLogout = async () => { |
23 | 15 | await logout(); |
| 16 | + setShowUserMenu(false); |
24 | 17 | }; |
25 | 18 |
|
26 | 19 | return ( |
27 | 20 | <header className="bg-white shadow-sm border-b border-gray-200"> |
28 | 21 | <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"> |
29 | 22 | <div className="flex justify-between items-center h-16"> |
30 | 23 | {/* 로고 */} |
31 | | - <div |
32 | | - onClick={handleLogoClick} |
33 | | - className="flex items-center cursor-pointer" |
34 | | - > |
35 | | - <div className="flex items-center space-x-2"> |
36 | | - <div className="w-8 h-8 bg-blue-600 rounded-full flex items-center justify-center"> |
37 | | - <span className="text-white text-xl font-bold">∞</span> |
38 | | - </div> |
39 | | - <span className="text-xl font-semibold text-gray-900">PathFinder</span> |
40 | | - </div> |
41 | | - </div> |
| 24 | + <Link href="/" className="flex items-center"> |
| 25 | + <Image |
| 26 | + src="/icon/logo.svg" |
| 27 | + alt="PathFinder" |
| 28 | + width={140} |
| 29 | + height={40} |
| 30 | + className="h-8" |
| 31 | + priority |
| 32 | + /> |
| 33 | + </Link> |
42 | 34 |
|
43 | | - {/* Navigation - 로그인 상태일 때만 표시 */} |
44 | | - {isLoggedIn && ( |
45 | | - <nav className="hidden md:flex space-x-8"> |
46 | | - {NAVIGATION_ITEMS.map((item) => ( |
47 | | - <Link |
48 | | - key={item.href} |
49 | | - href={item.href} |
50 | | - className="text-gray-700 hover:text-blue-600 font-medium transition-colors duration-200" |
51 | | - > |
52 | | - {item.label} |
53 | | - </Link> |
54 | | - ))} |
55 | | - </nav> |
56 | | - )} |
| 35 | + {/* 네비게이션 메뉴 */} |
| 36 | + <nav className="hidden md:flex space-x-8"> |
| 37 | + <Link |
| 38 | + href="/job-recommendations" |
| 39 | + className="text-gray-600 hover:text-gray-900 px-3 py-2 text-sm font-medium transition-colors" |
| 40 | + > |
| 41 | + 직무 추천 |
| 42 | + </Link> |
| 43 | + <Link |
| 44 | + href="/job-roadmaps" |
| 45 | + className="text-gray-600 hover:text-gray-900 px-3 py-2 text-sm font-medium transition-colors" |
| 46 | + > |
| 47 | + 직무 리스트 |
| 48 | + </Link> |
| 49 | + <Link |
| 50 | + href="/job-roadmaps" |
| 51 | + className="text-gray-600 hover:text-gray-900 px-3 py-2 text-sm font-medium transition-colors" |
| 52 | + > |
| 53 | + 직무 로드맵 |
| 54 | + </Link> |
| 55 | + </nav> |
57 | 56 |
|
58 | | - {/* Auth Links */} |
| 57 | + {/* 사용자 영역 */} |
59 | 58 | <div className="flex items-center space-x-4"> |
60 | | - {!isLoading && ( |
61 | | - <> |
62 | | - {isLoggedIn && user ? ( |
63 | | - <div className="flex items-center space-x-4"> |
64 | | - <span className="text-gray-700 font-medium"> |
65 | | - {user.nickname}님 |
| 59 | + {isLoggedIn && user ? ( |
| 60 | + <div className="relative"> |
| 61 | + {/* 사용자 메뉴 버튼 */} |
| 62 | + <button |
| 63 | + onClick={() => setShowUserMenu(!showUserMenu)} |
| 64 | + className="flex items-center space-x-2 text-gray-700 hover:text-gray-900 px-3 py-2 rounded-md text-sm font-medium transition-colors" |
| 65 | + > |
| 66 | + <div className="w-8 h-8 bg-[#103D5E] rounded-full flex items-center justify-center"> |
| 67 | + <span className="text-white text-sm font-semibold"> |
| 68 | + {user.nickname.charAt(0).toUpperCase()} |
66 | 69 | </span> |
67 | | - <button |
68 | | - onClick={handleLogout} |
69 | | - className="text-gray-500 hover:text-gray-700 font-medium transition-colors duration-200" |
70 | | - > |
71 | | - 로그아웃 |
72 | | - </button> |
73 | 70 | </div> |
74 | | - ) : ( |
| 71 | + <span>{user.nickname}</span> |
| 72 | + <svg className={`w-4 h-4 transition-transform ${showUserMenu ? 'rotate-180' : ''}`} |
| 73 | + fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 74 | + <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} |
| 75 | + d="M19 9l-7 7-7-7"/> |
| 76 | + </svg> |
| 77 | + </button> |
| 78 | + |
| 79 | + {/* 드롭다운 메뉴 */} |
| 80 | + {showUserMenu && ( |
75 | 81 | <> |
76 | | - <Link |
77 | | - href="/login" |
78 | | - className="text-gray-700 hover:text-blue-600 font-medium transition-colors duration-200" |
79 | | - > |
80 | | - 로그인 |
81 | | - </Link> |
82 | | - <span className="text-gray-300">/</span> |
83 | | - <Link |
84 | | - href="/signup" |
85 | | - className="text-gray-700 hover:text-blue-600 font-medium transition-colors duration-200" |
86 | | - > |
87 | | - 회원가입 |
88 | | - </Link> |
| 82 | + {/* 백드롭 */} |
| 83 | + <div |
| 84 | + className="fixed inset-0 z-10" |
| 85 | + onClick={() => setShowUserMenu(false)} |
| 86 | + /> |
| 87 | + |
| 88 | + {/* 메뉴 */} |
| 89 | + <div |
| 90 | + className="absolute right-0 mt-2 w-48 bg-white rounded-md shadow-lg py-1 z-20 border border-gray-200"> |
| 91 | + <Link |
| 92 | + href="/mypage" |
| 93 | + className="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 transition-colors" |
| 94 | + onClick={() => setShowUserMenu(false)} |
| 95 | + > |
| 96 | + 마이페이지 |
| 97 | + </Link> |
| 98 | + <button |
| 99 | + onClick={handleLogout} |
| 100 | + className="block w-full text-left px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 transition-colors" |
| 101 | + > |
| 102 | + 로그아웃 |
| 103 | + </button> |
| 104 | + </div> |
89 | 105 | </> |
90 | 106 | )} |
91 | | - </> |
| 107 | + </div> |
| 108 | + ) : ( |
| 109 | + <div className="flex items-center space-x-3"> |
| 110 | + <Link |
| 111 | + href="/login" |
| 112 | + className="text-gray-600 hover:text-gray-900 px-3 py-2 text-sm font-medium transition-colors" |
| 113 | + > |
| 114 | + 로그인 |
| 115 | + </Link> |
| 116 | + <Link |
| 117 | + href="/signup" |
| 118 | + className="bg-[#103D5E] hover:bg-[#0E3450] text-white px-4 py-2 rounded-md text-sm font-medium transition-colors" |
| 119 | + > |
| 120 | + 회원가입 |
| 121 | + </Link> |
| 122 | + </div> |
92 | 123 | )} |
93 | 124 | </div> |
| 125 | + </div> |
| 126 | + </div> |
94 | 127 |
|
95 | | - {/* 모바일 메뉴 버튼 (로그인 상태일 때만) */} |
96 | | - {isLoggedIn && ( |
97 | | - <div className="md:hidden"> |
98 | | - <button |
99 | | - type="button" |
100 | | - className="text-gray-700 hover:text-blue-600 focus:outline-none" |
101 | | - > |
102 | | - <svg className="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor"> |
103 | | - <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 6h16M4 12h16M4 18h16" /> |
104 | | - </svg> |
105 | | - </button> |
106 | | - </div> |
107 | | - )} |
| 128 | + {/* 모바일 네비게이션 (필요시 추가) */} |
| 129 | + <div className="md:hidden border-t border-gray-200"> |
| 130 | + <div className="px-2 pt-2 pb-3 space-y-1"> |
| 131 | + <Link |
| 132 | + href="/job-recommendations" |
| 133 | + className="block text-gray-600 hover:text-gray-900 px-3 py-2 text-base font-medium" |
| 134 | + > |
| 135 | + 직무 추천 |
| 136 | + </Link> |
| 137 | + <Link |
| 138 | + href="/job-roadmaps" |
| 139 | + className="block text-gray-600 hover:text-gray-900 px-3 py-2 text-base font-medium" |
| 140 | + > |
| 141 | + 직무 리스트 |
| 142 | + </Link> |
| 143 | + <Link |
| 144 | + href="/job-roadmaps" |
| 145 | + className="block text-gray-600 hover:text-gray-900 px-3 py-2 text-base font-medium" |
| 146 | + > |
| 147 | + 직무 로드맵 |
| 148 | + </Link> |
108 | 149 | </div> |
109 | 150 | </div> |
110 | 151 | </header> |
|
0 commit comments