|
| 1 | +// src/components/layout/header/nav.tsx (์์ ๊ฒฝ๋ก) |
1 | 2 | import { getUserAlerts, markAlertRead } from '@/api/alerts'; |
2 | 3 | import { Icon } from '@/components/ui'; |
3 | 4 | import Notification, { type Alert } from '@/components/ui/modal/notification/Notification'; |
@@ -32,7 +33,7 @@ const Nav = () => { |
32 | 33 |
|
33 | 34 | // 1) ์๋ฒ ์๋ฆผ ๋ถ๋ฌ์ค๊ธฐ (์ฌ์ฅ๋/์๋ฐ ๊ณตํต) |
34 | 35 | useEffect(() => { |
35 | | - if (!isLogin || !user?.id || role !== 'employer') { |
| 36 | + if (!isLogin || !user?.id) { |
36 | 37 | setApiAlerts([]); |
37 | 38 | return; |
38 | 39 | } |
@@ -72,7 +73,6 @@ const Nav = () => { |
72 | 73 | // 3) ์ค์ ํ์ํ ์๋ฆผ: ์๋ฒ ๊ฒฐ๊ณผ๊ฐ ์์ผ๋ฉด ์ฐ์ , ์์ผ๋ฉด(ํนํ ์ง์) fallback |
73 | 74 | const alerts: Alert[] = useMemo(() => { |
74 | 75 | const base = apiAlerts.length > 0 ? apiAlerts : fallbackAlertsForEmployee; |
75 | | - // ๋ก์ปฌ ์ฝ์ ์ธํธ ๋ฐ์(์๋ฒ ์๋ฆผ์๋ ์ ์ฉ) |
76 | 76 | return base.map(a => (readIds.has(a.id) ? { ...a, read: true } : a)); |
77 | 77 | }, [apiAlerts, fallbackAlertsForEmployee, readIds]); |
78 | 78 |
|
@@ -105,48 +105,49 @@ const Nav = () => { |
105 | 105 | </Link> |
106 | 106 | ))} |
107 | 107 |
|
108 | | - {isLogin && role === 'employee' && ( |
109 | | - <> |
| 108 | + {/* ๋ก๊ทธ์ธํ ๋๊ตฌ๋ ๋ก๊ทธ์์ ๋
ธ์ถ */} |
| 109 | + {isLogin && ( |
| 110 | + <button |
| 111 | + type='button' |
| 112 | + onClick={e => { |
| 113 | + e.preventDefault(); |
| 114 | + logout('/'); |
| 115 | + }} |
| 116 | + > |
| 117 | + ๋ก๊ทธ์์ |
| 118 | + </button> |
| 119 | + )} |
| 120 | + |
| 121 | + {/* โ
์ฌ์ฅ๋(employer)์๊ฒ๋ง ์๋ฆผ ๋ฒํผ ์จ๊น */} |
| 122 | + {isLogin && role !== 'employer' && ( |
| 123 | + <div className='relative'> |
110 | 124 | <button |
111 | 125 | type='button' |
112 | | - onClick={e => { |
113 | | - e.preventDefault(); |
114 | | - logout('/'); |
115 | | - }} |
| 126 | + aria-label='์๋ฆผ ํ์ธํ๊ธฐ' |
| 127 | + aria-expanded={open} |
| 128 | + aria-controls='notification-panel' |
| 129 | + onClick={() => setOpen(v => !v)} |
| 130 | + className='relative' |
116 | 131 | > |
117 | | - ๋ก๊ทธ์์ |
| 132 | + <Icon |
| 133 | + key={open ? 'bell-on' : 'bell-off'} |
| 134 | + iconName={bellIcon} |
| 135 | + iconSize='rg' |
| 136 | + bigScreenSize='md' |
| 137 | + ariaLabel='์๋ฆผ' |
| 138 | + className={bellColor} |
| 139 | + /> |
118 | 140 | </button> |
119 | 141 |
|
120 | | - {/* ๋ก๊ทธ์ธ ์ฌ์ฉ์๋ ๋๊ตฌ๋ ์๋ฆผ ๋ฒํผ ๋
ธ์ถ (์ฌ์ฅ๋ ํฌํจ) */} |
121 | | - <div className='relative'> |
122 | | - <button |
123 | | - type='button' |
124 | | - aria-label='์๋ฆผ ํ์ธํ๊ธฐ' |
125 | | - aria-expanded={open} |
126 | | - aria-controls='notification-panel' |
127 | | - onClick={() => setOpen(v => !v)} |
128 | | - className='relative' |
129 | | - > |
130 | | - <Icon |
131 | | - key={open ? 'bell-on' : 'bell-off'} |
132 | | - iconName={bellIcon} |
133 | | - iconSize='rg' |
134 | | - bigScreenSize='md' |
135 | | - ariaLabel='์๋ฆผ' |
136 | | - className={bellColor} |
137 | | - /> |
138 | | - </button> |
139 | | - |
140 | | - {open && ( |
141 | | - <Notification |
142 | | - alerts={alerts} |
143 | | - onRead={handleRead} |
144 | | - isOpen={open} |
145 | | - onClose={() => setOpen(false)} |
146 | | - /> |
147 | | - )} |
148 | | - </div> |
149 | | - </> |
| 142 | + {open && ( |
| 143 | + <Notification |
| 144 | + alerts={alerts} |
| 145 | + onRead={handleRead} |
| 146 | + isOpen={open} |
| 147 | + onClose={() => setOpen(false)} |
| 148 | + /> |
| 149 | + )} |
| 150 | + </div> |
150 | 151 | )} |
151 | 152 | </nav> |
152 | 153 | ); |
|
0 commit comments