+
diff --git a/src/app/(crew)/my-gathering/layout.tsx b/src/app/(crew)/my-gathering/layout.tsx
index 3b0f6747..2567dd3f 100644
--- a/src/app/(crew)/my-gathering/layout.tsx
+++ b/src/app/(crew)/my-gathering/layout.tsx
@@ -1,47 +1,41 @@
'use client';
import { useEffect, useState } from 'react';
-import Link from 'next/link';
-import { usePathname } from 'next/navigation';
-import { Button } from '@mantine/core';
+import { usePathname, useRouter } from 'next/navigation';
+import Tabs from '@/src/components/common/tab';
-const buttonData = [
- { id: 1, label: '참여한 약속', route: '/my-gathering/participation' },
- { id: 2, label: '만든 약속', route: '/my-gathering/creation' },
- { id: 3, label: '찜한 약속', route: '/my-gathering/favorite' },
+const myGatheringTabs = [
+ { id: 'my-gathering-participation', label: '참여한 약속', route: '/my-gathering/participation' },
+ { id: 'my-gathering-creation', label: '만든 약속', route: '/my-gathering/creation' },
];
-const getSelectedButtonIndex = (currentPath: string) => {
- return buttonData.findIndex(({ route }) => currentPath.endsWith(route.split('/').pop()!)) + 1;
-};
-
export default function MyGatheringLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
+ const router = useRouter();
const currentPath = usePathname();
-
- const [selectedButton, setSelectedButton] = useState(getSelectedButtonIndex(currentPath));
+ const [currentTab, setCurrentTab] = useState('');
useEffect(() => {
- const newIdx = getSelectedButtonIndex(currentPath);
- setSelectedButton(newIdx);
+ const activeTabId = myGatheringTabs.find((tab) => tab.route === currentPath)?.id;
+ if (activeTabId) setCurrentTab(activeTabId);
}, [currentPath]);
+ const handleTabClick = (id: string) => {
+ const targetRoute = myGatheringTabs.find((tab) => tab.id === id)?.route;
+ if (targetRoute) router.push(targetRoute);
+ };
+
return (
-
-
- {buttonData.map(({ id, label, route }) => (
-
-
-
- ))}
-
+
+ handleTabClick(id)}
+ />
{children}
);
diff --git a/src/app/(crew)/my-gathering/participation/page.tsx b/src/app/(crew)/my-gathering/participation/page.tsx
index c397878b..50c79a2a 100644
--- a/src/app/(crew)/my-gathering/participation/page.tsx
+++ b/src/app/(crew)/my-gathering/participation/page.tsx
@@ -52,8 +52,8 @@ export default function ParticipationPage() {
];
return (
-
-
+
+
diff --git a/src/components/common/tab/index.tsx b/src/components/common/tab/index.tsx
index 836820c5..912798e7 100644
--- a/src/components/common/tab/index.tsx
+++ b/src/components/common/tab/index.tsx
@@ -1,6 +1,7 @@
interface Tab {
label: string;
id: string;
+ route?: string;
}
export interface TabsProps {
@@ -13,7 +14,7 @@ export interface TabsProps {
/**
* Tabs
*
- * @param tabs - 탭 목록 데이터 배열로, 각 탭은 label과 id로 구성
+ * @param tabs - 탭 목록 데이터 배열로, 각 탭은 label, id, route로 구성
* @param activeTab - 현재 활성화된 탭의 ID
* @param onTabClick - 탭 클릭 시 호출되는 함수, 탭 ID를 매개변수로 받음
* @param variant - 탭 스타일 유형, 기본 값은 'default'이며 'review'로 전환 가능
diff --git a/src/styles/globals.css b/src/styles/globals.css
index 806c6031..904fbaad 100644
--- a/src/styles/globals.css
+++ b/src/styles/globals.css
@@ -36,7 +36,7 @@
}
@layer utilities {
.corner-dot {
- @apply absolute right-[-7px] top-[-6px] rounded-full bg-gray-300;
+ @apply absolute right-[-5px] top-[-6px] rounded-full bg-gray-300;
width: 12px;
height: 12px;
}