Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { gatheringData } from '@/src/mock/gathering-data';

export default function FavoritePage() {
return (
<div className="md:mt-[45px]">
<div className="mt-4 md:mt-10">
<GatheringList gatheringData={gatheringData} />
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ export default function GatheringListWithDate({ gatheringList }: GatheringListWi
}, [gatheringList]);

return (
<div className="m-4 md:mt-[32.5px]">
<div>
{gatheringListWithDateInfo.map((gathering) => (
<div key={gathering.id} className="md:flex">
<div className="relative w-1/6 md:border-r-2 md:border-gray-200">
<div className="w-1/6">
{gathering.isNewDate && (
<div>
<div className="md:corner-dot" />
<div className="hidden flex-nowrap md:block">
<div className="text-lg font-semibold">{formatDate(gathering.dateTime).date}</div>
<div className="text-base font-medium text-gray-500">μ›”μš”μΌ</div>
</div>
<div className="hidden flex-nowrap md:block">
<div className="text-lg font-semibold">{formatDate(gathering.dateTime).date}</div>
<div className="text-base font-medium text-gray-500">μ›”μš”μΌ</div>
Comment on lines +28 to +30
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ› οΈ Refactor suggestion

λ‚ μ§œ ν‘œμ‹œ μ„Ήμ…˜μ˜ νƒ€μ΄ν¬κ·Έλž˜ν”Ό κ°œμ„ μ΄ ν•„μš”ν•©λ‹ˆλ‹€.

ν˜„μž¬ μš”μΌμ΄ ν•˜λ“œμ½”λ”©λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€. formatDate μœ ν‹Έλ¦¬ν‹°λ₯Ό ν™œμš©ν•˜μ—¬ λ™μ μœΌλ‘œ μš”μΌμ„ ν‘œμ‹œν•˜λŠ” 것이 μ’‹κ² μŠ΅λ‹ˆλ‹€.

-<div className="text-base font-medium text-gray-500">μ›”μš”μΌ</div>
+<div className="text-base font-medium text-gray-500">{formatDate(gathering.dateTime).dayOfWeek}</div>
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<div className="hidden flex-nowrap md:block">
<div className="text-lg font-semibold">{formatDate(gathering.dateTime).date}</div>
<div className="text-base font-medium text-gray-500">μ›”μš”μΌ</div>
<div className="hidden flex-nowrap md:block">
<div className="text-lg font-semibold">{formatDate(gathering.dateTime).date}</div>
<div className="text-base font-medium text-gray-500">{formatDate(gathering.dateTime).dayOfWeek}</div>

</div>
)}
</div>
<div className={`${gathering.isNewDate ? 'pb-' : 'p-'} flex-1 pb-6 md:pl-8`}>
<div className={`${gathering.isNewDate && 'mt-3.5'} relative -mb-3.5 w-0.5 bg-gray-200`}>
{gathering.isNewDate && <div className="md:corner-dot" />}
</div>
<div className="flex-1 pb-6 md:pl-8">
<ScheduledGatheringCard key={gathering.id} data={gathering} />
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/app/(crew)/my-gathering/creation/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ export default function CreationPage() {
];

return (
<div className="">
<div className="pl-4 md:pt-2">
<div>
<div className="py-4 md:py-6">
<PopOverCalendar value={selectedDate} onChange={(d) => setSelectedDate(d)} />
</div>
<GatheringListWithDate gatheringList={creationGatheringList} />
Expand Down
48 changes: 21 additions & 27 deletions src/app/(crew)/my-gathering/layout.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<div className="mt-4 md:mx-[46px] md:mt-[45px]">
<div className="m-4 grid grid-cols-3 gap-2 md:gap-4">
{buttonData.map(({ id, label, route }) => (
<Link key={id} href={route}>
<Button
className={`${id === selectedButton ? 'btn-filled' : 'btn-outlined'} w-full text-sm font-bold md:text-lg`}
>
{label}
</Button>
</Link>
))}
</div>
<div className="px-3 py-8 md:px-8 md:py-12.5 lg:px-11.5">
<Tabs
variant="default"
tabs={myGatheringTabs}
activeTab={currentTab}
onTabClick={(id) => handleTabClick(id)}
/>
{children}
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions src/app/(crew)/my-gathering/participation/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export default function ParticipationPage() {
];

return (
<div className="">
<div className="pl-4 md:pt-2">
<div>
<div className="py-4 md:py-6">
<PopOverCalendar value={selectedDate} onChange={(d) => setSelectedDate(d)} />
</div>
<GatheringListWithDate gatheringList={creationGatheringList} />
Expand Down
3 changes: 2 additions & 1 deletion src/components/common/tab/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
interface Tab {
label: string;
id: string;
route?: string;
}

export interface TabsProps {
Expand All @@ -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'둜 μ „ν™˜ κ°€λŠ₯
Expand Down
2 changes: 1 addition & 1 deletion src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

였 이런 방법도 μžˆκ΅°μš”!! μ‹ κΈ°ν•©λ‹ˆλ‹€~~~

width: 12px;
height: 12px;
}
Expand Down