Skip to content

Commit 5e03558

Browse files
committed
refact: 로그인 상태에서만 로그아웃 버튼 활성화로 수정
1 parent 2650e8a commit 5e03558

2 files changed

Lines changed: 23 additions & 11 deletions

File tree

src/pages/menu/ui/MenuPage.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { flexColumn } from '../../../../design-system/styles/flex';
22
import HorizontalCardButton from '../../../../design-system/ui/buttons/HorizontalCardButton';
33
import { useNavigate } from 'react-router-dom';
44
import Header from '../../../../design-system/ui/Header';
5-
import { buttonData } from '../../../shared/types/menuType';
5+
import { getButtonData } from '../../../shared/types/menuType';
66
import BottomBar from '../../../widgets/main/ui/BottomBar';
77

88
const handleIconClick = (navigate: (path: string) => void, path: string) => {
@@ -11,12 +11,11 @@ const handleIconClick = (navigate: (path: string) => void, path: string) => {
1111

1212
const MenuPage = () => {
1313
const navigate = useNavigate();
14+
const buttonData = getButtonData();
1415

1516
return (
1617
<>
17-
<Header
18-
centerContent="메뉴"
19-
/>
18+
<Header centerContent="메뉴" />
2019
<div className={`${flexColumn} gap-4 px-8 md:px-10 mt-8`}>
2120
{buttonData.map((button, index) => (
2221
<div key={button.label}>

src/shared/types/menuType.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import SelectedEvent from '../../..//design-system/icons/SelectedEvent.svg';
88
import SelectedHost from '../../../public/assets/menu/SelectedHost.svg';
99
import SelectedLogout from '../../../public/assets/menu/SelectedLogout.svg';
1010
import SelectedSetting from '../../../public/assets/menu/SelectedSetting.svg';
11+
import useAuthStore from '../../app/provider/authStore';
1112

1213
export interface buttonData {
1314
iconPath: string; // 아이콘 경로
@@ -16,10 +17,22 @@ export interface buttonData {
1617
path: string; // 경로
1718
}
1819

19-
export const buttonData: buttonData[] = [
20-
{ iconPath: Ticket, hoverIconPath: SelectedTicket, label: '구입한 티켓', path: '/menu/myTicket' },
21-
{ iconPath: Host, hoverIconPath: SelectedHost, label: '내 호스트', path: '/menu/myHost' },
22-
{ iconPath: Event, hoverIconPath: SelectedEvent, label: '이벤트 주최하기', path: '/event-creation' },
23-
{ iconPath: Setting, hoverIconPath: SelectedSetting, label: '마이페이지', path: '/menu/myPage' },
24-
{ iconPath: Logout, hoverIconPath: SelectedLogout, label: '로그아웃', path: '/menu/logout' },
25-
];
20+
export const getButtonData = (): buttonData[] => {
21+
const isLoggedIn = useAuthStore.getState().isLoggedIn;
22+
23+
const baseButtons: buttonData[] = [
24+
{ iconPath: Ticket, hoverIconPath: SelectedTicket, label: '구입한 티켓', path: '/menu/myTicket' },
25+
{ iconPath: Host, hoverIconPath: SelectedHost, label: '내 호스트', path: '/menu/myHost' },
26+
{ iconPath: Event, hoverIconPath: SelectedEvent, label: '이벤트 주최하기', path: '/event-creation' },
27+
{ iconPath: Setting, hoverIconPath: SelectedSetting, label: '마이페이지', path: '/menu/myPage' },
28+
];
29+
30+
if (isLoggedIn) {
31+
return [
32+
...baseButtons,
33+
{ iconPath: Logout, hoverIconPath: SelectedLogout, label: '로그아웃', path: '/menu/logout' },
34+
];
35+
}
36+
37+
return baseButtons;
38+
};

0 commit comments

Comments
 (0)