Skip to content

Commit

Permalink
feat: 크루 가입 수락/거절 요청에 대한 토스트 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
1g2g committed Nov 28, 2023
1 parent 1386aa8 commit 8a6bd1f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/hooks/mutations/useAllowCrewParticipateMutation.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import toast from 'react-hot-toast';

import { useMutation } from '@tanstack/react-query';
import { useQueryClient } from '@tanstack/react-query';

Expand All @@ -9,11 +11,16 @@ export const useAllowCrewParticipateMutation = () => {
return useMutation({
mutationFn: patchCrewParticipate,
onSuccess: (_, variables) => {
toast.success('크루 가입을 수락했습니다.');

const { crewId } = variables;

queryClient.invalidateQueries({
queryKey: ['crew-members', crewId, '대기'],
});
},
onError: () => {
toast.error('크루 가입를 수락하지 못 했습니다. 다시 한 번 시도해주세요.');
},
});
};
7 changes: 7 additions & 0 deletions src/hooks/mutations/useDisallowCrewParticipateMutation.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import toast from 'react-hot-toast';

import { useMutation } from '@tanstack/react-query';
import { useQueryClient } from '@tanstack/react-query';

Expand All @@ -9,11 +11,16 @@ export const useDisallowCrewParticipateMutation = () => {
return useMutation({
mutationFn: deleteCrewParticipate,
onSuccess: (_, variables) => {
toast.success('크루 가입을 거절했습니다.');

const { crewId } = variables;

queryClient.invalidateQueries({
queryKey: ['crew-members', crewId, '대기'],
});
},
onError: () => {
toast.error('크루 가입를 거절하지 못 했습니다. 다시 한 번 시도해주세요.');
},
});
};

0 comments on commit 8a6bd1f

Please sign in to comment.