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
9 changes: 9 additions & 0 deletions src/app/group/[groupId]/actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use server';

import { revalidatePath } from 'next/cache';

export const revalidateGroupAction = async (groupId: string) => {
// 모임 취소 (useDeleteGroup) Mutation 이후 해당 groupId의 상세 페이지의 RSC 캐싱을 무효 처리함.
// RSC 캐싱을 무효화 해야만, History Back을 통해 재진입하더라도 RSC의 캐싱 데이터를 보여주지 않음.
revalidatePath(`/group/${groupId}`);
};
4 changes: 3 additions & 1 deletion src/components/pages/group/group-modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { useParams, useRouter } from 'next/navigation';

import { revalidateGroupAction } from '@/app/group/[groupId]/actions';
import { GroupModalApprovalContent } from '@/components/pages/group/group-modal/approval-content';
import { GroupModalCommonContent } from '@/components/pages/group/group-modal/common-content';
import { Toast } from '@/components/ui';
Expand Down Expand Up @@ -32,8 +33,8 @@ type Props = BaseProps | KickProps;
export const GroupModal = (props: Props) => {
const { type } = props;

const { replace } = useRouter();
const { groupId } = useParams() as { groupId: string };
const { replace } = useRouter();
const { run } = useToast();

const { mutateAsync: attendMutate, isPending: isAttending } = useAttendGroup({ groupId });
Expand All @@ -60,6 +61,7 @@ export const GroupModal = (props: Props) => {
leave: () => leaveMutate(),
delete: async () => {
await deleteMutate();
await revalidateGroupAction(groupId);
replace('/');
},
kick: () => kickMutate(),
Expand Down