From 73536d74df1725932241b01809c5a4023e66a9e1 Mon Sep 17 00:00:00 2001 From: yujin5959 Date: Wed, 29 Jul 2026 18:19:09 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EA=B3=B5=EC=9C=A0=20=EC=9D=B4=EB=B2=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=86=8C=EC=9C=A0=EC=9E=90=20=ED=8C=90=EB=8B=A8=20?= =?UTF-8?q?=EB=B0=8F=20=EC=B6=94=EA=B0=80=20API=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/features/Friends/SharedScheduleItem.tsx | 30 +++++++++++++-------- src/pages/main/FriendsPage/FriendsPage.tsx | 1 + src/shared/api/friends/eventShare.ts | 6 +++++ src/shared/types/eventShare/eventShare.ts | 1 + 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/features/Friends/SharedScheduleItem.tsx b/src/features/Friends/SharedScheduleItem.tsx index 53cad40..7e111d6 100644 --- a/src/features/Friends/SharedScheduleItem.tsx +++ b/src/features/Friends/SharedScheduleItem.tsx @@ -13,6 +13,7 @@ interface SharedScheduleItemProps { endDate?: string sharerName: string accentColor: string + isOwner?: boolean onCancelSuccess?: () => void } @@ -23,6 +24,7 @@ export default function SharedScheduleItem({ endDate, sharerName = '이름없음', accentColor = '#5c6ac4', + isOwner = false, onCancelSuccess, }: SharedScheduleItemProps) { const queryClient = useQueryClient() @@ -44,25 +46,27 @@ export default function SharedScheduleItem({ ? formatDate(startDate) : `${formatDate(startDate)} - ${formatDate(endDate)}` - const leaveEventMutation = useMutation({ - mutationFn: () => eventShareApi.leaveEvent(eventId), + const cancelShareMutation = useMutation({ + mutationFn: () => + isOwner ? eventShareApi.deleteEventParticipants(eventId) : eventShareApi.leaveEvent(eventId), onSuccess: (response) => { if (response.isSuccess) { queryClient.invalidateQueries({ queryKey: ['calendar'] }) queryClient.invalidateQueries({ queryKey: ['events'] }) queryClient.invalidateQueries({ queryKey: ['todos'] }) + queryClient.invalidateQueries({ queryKey: ['sharedEvents'] }) showToast({ - title: '그룹 탈퇴 완료', - message: '성공적으로 탈퇴되었습니다.', + title: isOwner ? '공유 해제 완료' : '그룹 탈퇴 완료', + message: isOwner ? '성공적으로 공유가 해제되었습니다.' : '성공적으로 탈퇴되었습니다.', toastType: 'success', }) onCancelSuccess?.() } else { showToast({ - title: '탈퇴 처리 실패', - message: response.message || '탈퇴 처리에 실패했습니다.', + title: isOwner ? '공유 해제 실패' : '탈퇴 처리 실패', + message: response.message || '처리에 실패했습니다.', toastType: 'error', }) } @@ -80,8 +84,12 @@ export default function SharedScheduleItem({ }) const handleCancelShare = () => { - if (window.confirm('정말 이 공유 이벤트에서 탈퇴하시겠습니까?')) { - leaveEventMutation.mutate() + const confirmMessage = isOwner + ? '소유자가 공유를 해제하면 다른 참가자들의 공유 일정도 함께 삭제됩니다. 정말 공유를 해제하시겠습니까?' + : '정말 이 공유 이벤트에서 탈퇴하시겠습니까?' + + if (window.confirm(confirmMessage)) { + cancelShareMutation.mutate() } } @@ -94,14 +102,14 @@ export default function SharedScheduleItem({ - 공유자: {sharerName} + {isOwner ? '내 이벤트(Owner)' : `공유자: ${sharerName}`} - {leaveEventMutation.isPending ? '취소 중...' : '공유 취소'} + {cancelShareMutation.isPending ? '처리 중...' : isOwner ? '공유 해제' : '공유 취소'} diff --git a/src/pages/main/FriendsPage/FriendsPage.tsx b/src/pages/main/FriendsPage/FriendsPage.tsx index f01c9e0..0073312 100644 --- a/src/pages/main/FriendsPage/FriendsPage.tsx +++ b/src/pages/main/FriendsPage/FriendsPage.tsx @@ -219,6 +219,7 @@ export default function FriendsPage() { endDate={item.endDate} sharerName={item.ownerName} accentColor={getAccentColor(index + 3)} + isOwner={item.isOwner} onCancelSuccess={handleActionSuccess} /> )) diff --git a/src/shared/api/friends/eventShare.ts b/src/shared/api/friends/eventShare.ts index d234902..23a077c 100644 --- a/src/shared/api/friends/eventShare.ts +++ b/src/shared/api/friends/eventShare.ts @@ -33,6 +33,12 @@ export const eventShareApi = { const { data } = await axiosInstance.get(`${BASE_URL}/invitations`) return data }, + deleteEventParticipants: async (eventId: number): Promise => { + const { data } = await axiosInstance.delete( + `/events/${eventId}/participants`, + ) + return data + }, leaveEvent: async (eventId: number): Promise => { const { data } = await axiosInstance.delete( `/events/${eventId}/participants/leave`, diff --git a/src/shared/types/eventShare/eventShare.ts b/src/shared/types/eventShare/eventShare.ts index 43ffe2e..3edfeea 100644 --- a/src/shared/types/eventShare/eventShare.ts +++ b/src/shared/types/eventShare/eventShare.ts @@ -3,6 +3,7 @@ import type { TCommonResponse } from '../common/common' export interface SharedEvent { eventId: number ownerName: string + isOwner: boolean title: string startDate: string endDate: string