Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions src/app/schedule/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import { useSearchParams } from 'next/navigation';

import { Suspense } from 'react';

import { TabNavigation } from '@/components/shared';

import Current from './(components)/current';
Expand All @@ -14,17 +16,32 @@ const SCHEDULE_TABS = [
{ label: '모임 이력', value: 'history' },
];

export default function SchedulePage() {
const ScheduleContent = () => {
const searchParams = useSearchParams();
const tab = searchParams.get('tab') || 'current';

return (
<div className='min-h-screen bg-[#F1F5F9]'>
<TabNavigation basePath='/schedule' tabs={SCHEDULE_TABS} />

<>
{tab === 'current' && <Current />}
{tab === 'my' && <My />}
{tab === 'history' && <History />}
</>
);
};

export default function SchedulePage() {
return (
<div className='min-h-screen bg-[#F1F5F9]'>
<TabNavigation basePath='/schedule' tabs={SCHEDULE_TABS} />

<Suspense fallback={null}>
<ScheduleContent />
</Suspense>
</div>
);
}

// 나중에 api 연동할 때
// 1. ScheduleContent를 감싸던 임시 Suspense 제거해야됨
// 2. useSearchParams()는 그대로 유지
// 3. Current, My, History를 서버 컴포넌트로 변경 (use client 제거) - 서버에서 데이터 페칭
13 changes: 12 additions & 1 deletion src/components/shared/tab-navigation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import Link from 'next/link';
import { useSearchParams } from 'next/navigation';

import { Suspense } from 'react';

import { cn } from '@/lib/utils';

export interface Tab {
Expand Down Expand Up @@ -46,7 +48,7 @@ const TabItem = ({ label, href, isActive }: TabItemProps) => (
</li>
);

export const TabNavigation = ({ tabs, paramName = 'tab', basePath = '' }: TabNavigationProps) => {
const TabNavigationInner = ({ tabs, paramName = 'tab', basePath = '' }: TabNavigationProps) => {
const searchParams = useSearchParams();
const currentTab = searchParams.get(paramName) || tabs[0].value;

Expand All @@ -66,3 +68,12 @@ export const TabNavigation = ({ tabs, paramName = 'tab', basePath = '' }: TabNav
</nav>
);
};

export const TabNavigation = (props: TabNavigationProps) => {
return (
// 나중에 레이아웃으로 뺄거임 임시
<Suspense fallback={null}>
<TabNavigationInner {...props} />
</Suspense>
);
};