diff --git a/src/components/common/gathering-card/scheduled-gathering-card/container.tsx b/src/components/common/gathering-card/scheduled-gathering-card/container.tsx
index 33de86a9..b05a00df 100644
--- a/src/components/common/gathering-card/scheduled-gathering-card/container.tsx
+++ b/src/components/common/gathering-card/scheduled-gathering-card/container.tsx
@@ -1,90 +1,39 @@
-import { useCallback, useState } from 'react';
+import { useCallback, useEffect, useState } from 'react';
+import { toast } from 'react-toastify';
+import { ApiError } from 'next/dist/server/api-utils';
+import { useGetGatheringDetailQuery } from '@/src/_queries/gathering/gathering-detail-queries';
import GatheringDetailModalContainer from '@/src/app/(crew)/crew/detail/[id]/_components/gathering-detail-modal/container';
+import { GatheringCardProps } from '@/src/types/gathering-data';
import ScheduledGatheringCardPresenter from './presenter';
-interface ScheduledGatheringCardContainerProps {
- data: {
- id: number;
- crewTitle: string;
- crewMainLocation: string;
- crewSubLocation: string;
- title: string;
- dateTime: string;
- currentCount: number;
- totalCount: number;
- imageUrl: string;
- liked: boolean;
- };
-}
-
-export default function ScheduledGatheringCardContainer({
- data,
-}: ScheduledGatheringCardContainerProps) {
+export default function ScheduledGatheringCardContainer({ data }: { data: GatheringCardProps }) {
const [isOpened, setIsOpened] = useState(false);
- // TODO: modalData 연결
- // const { data: modalData } = useQuery(useGetGatheringQuery());
- const dummyModalData = {
- crewId: 7,
- id: 1,
- title: '신나는 운동...즐거운..코딩..',
- introduce: '공지사항입니다. 다들 이번 약속 잊지 않으셨죠? 꼭 참여 부탁드립니다~',
- dateTime: '2024-10-29T00:32:12.306Z',
- location: '서울시 강남구 역삼동 오피스타워 3층',
- currentCount: 3,
- totalCount: 10,
- imageUrl:
- 'https://www.dabur.com/Blogs/Doshas/Importance%20and%20Benefits%20of%20Yoga%201020x450.jpg',
- liked: false,
- gatheringCaptain: false,
- participant: false,
- participants: [
- {
- id: 1,
- profileImageUrl:
- 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQUMrcQB5OJ-ETzPc6wHnjxjC-36__MGw3JcA&s',
- nickname: '럽윈즈올',
- email: 'youl@email.com',
- },
- {
- id: 2,
- profileImageUrl:
- 'https://imgcdn.stablediffusionweb.com/2024/5/13/c0541236-e690-4dff-a27e-30a0355e5ea0.jpg',
- nickname: '모닝러너',
- email: 'youl@email.com',
- },
- {
- id: 3,
- profileImageUrl:
- 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQUMrcQB5OJ-ETzPc6wHnjxjC-36__MGw3JcA&s',
- nickname: '동글동글이',
- email: 'youl@email.com',
- },
- ],
- };
+ const { data: gatheringData, error } = useGetGatheringDetailQuery(data.crewId, data.id);
- const handleCardClick = useCallback(() => {
- setIsOpened(true);
- // TODO: retry or refetch사용해서 useQuery부분 안으로 넣기
- }, []);
+ useEffect(() => {
+ if (error) {
+ if (error instanceof ApiError) {
+ const errorData = JSON.parse(error.message);
+ if (errorData.status === 'NOT_FOUND') {
+ toast.error('모임 정보를 찾을 수 없습니다.');
+ }
+ } else {
+ toast.error('데이터 통신에 실패했습니다.');
+ }
+ }
+ }, [error]);
- const handleLikeToggle = useCallback(() => {
- alert('좋아요 토글됨'); // TODO: 좋아요 토글 로직 구현
- }, []);
+ const handleCardClick = useCallback(() => setIsOpened(true), []);
+ const handleCloseModal = useCallback(() => setIsOpened(false), []);
return (
-
- {dummyModalData && (
+
+ {gatheringData && (
{
- setIsOpened(false);
- }}
- data={dummyModalData}
+ close={handleCloseModal}
+ data={gatheringData}
/>
)}
diff --git a/src/components/common/gathering-card/scheduled-gathering-card/presenter.tsx b/src/components/common/gathering-card/scheduled-gathering-card/presenter.tsx
index 4d9b2d45..522df903 100644
--- a/src/components/common/gathering-card/scheduled-gathering-card/presenter.tsx
+++ b/src/components/common/gathering-card/scheduled-gathering-card/presenter.tsx
@@ -18,13 +18,11 @@ interface ScheduledGatheringCardPresenterProps {
liked: boolean;
};
onClick: () => void;
- onLikeToggle: () => void;
}
export default function ScheduledGatheringCardPresenter({
data,
onClick,
- onLikeToggle,
}: ScheduledGatheringCardPresenterProps) {
const {
id,
@@ -96,9 +94,6 @@ export default function ScheduledGatheringCardPresenter({
참여인원 {currentCount}/{totalCount}
-
-
-
);
diff --git a/src/components/common/gathering-card/scheduled-gathering-card/scheduled-gathering.stories.tsx b/src/components/common/gathering-card/scheduled-gathering-card/scheduled-gathering.stories.tsx
index ef0b7845..2ebc5461 100644
--- a/src/components/common/gathering-card/scheduled-gathering-card/scheduled-gathering.stories.tsx
+++ b/src/components/common/gathering-card/scheduled-gathering-card/scheduled-gathering.stories.tsx
@@ -1,4 +1,5 @@
import type { Meta, StoryObj } from '@storybook/react';
+import ClientProvider from '@/src/components/client-provider';
import ScheduledGatheringCard from './container';
const meta: Meta = {
@@ -12,6 +13,13 @@ const meta: Meta = {
},
},
tags: ['autodocs'],
+ decorators: [
+ (Story) => (
+
+
+
+ ),
+ ],
argTypes: {},
} satisfies Meta;
@@ -23,6 +31,7 @@ export const LikedEvent: Story = {
args: {
data: {
id: 1,
+ crewId: 1,
crewTitle: '풀 엔 그레이스 스튜디오',
crewMainLocation: '서울시',
crewSubLocation: '강남구 역삼동',
@@ -42,6 +51,7 @@ export const NotLikedEvent: Story = {
args: {
data: {
id: 2,
+ crewId: 1,
crewTitle: '산악회 모임',
crewMainLocation: '서울시',
crewSubLocation: '용산구 한강로',
diff --git a/src/types/gathering-data.d.ts b/src/types/gathering-data.d.ts
index 7ebe3d23..18f4ec7d 100644
--- a/src/types/gathering-data.d.ts
+++ b/src/types/gathering-data.d.ts
@@ -47,6 +47,7 @@ export interface CreateGatheringRequestTypes {
export interface GatheringCardProps {
id: number;
+ crewId: number;
crewTitle: string;
crewMainLocation: string;
crewSubLocation: string;