Skip to content

Commit

Permalink
refactor(member): 불필요한 invalidateQueries 삭제
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeong-Ag committed Aug 18, 2024
1 parent 0735862 commit 7c1d0e2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { useMutation } from '@tanstack/react-query';

import { postApplicationAllMember } from '@api/application';
import { MEMBER_QUERY_KEY } from '@constants/key';
import useToast from '@hooks/common/useToast';

/**
* 모집 내 합격자 계정 일괄 생성
*/
export function useApplicationAllMemberMutation() {
const queryClient = useQueryClient();
const toast = useToast();

const mutation = useMutation({
mutationFn: postApplicationAllMember,
onSuccess: (data) => {
onSuccess: () => {
toast({
state: 'success',
message:
'멤버 일괄 생성이 완료되었어요.\n불합격 상태인 지원자의 계정이 생성되지 않아요.',
});

const queryKeys = data.map((member) => MEMBER_QUERY_KEY.MEMBER(member));

queryKeys.forEach((queryKey) => {
queryClient.invalidateQueries({ queryKey });
});
},
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { useMutation } from '@tanstack/react-query';

import { postApplicationMember } from '@api/application';
import { MEMBER_QUERY_KEY } from '@constants/key';
import useToast from '@hooks/common/useToast';

/**
* 합격자 멤버 단일 생성
*/
export function useApplicationMemberMutation() {
const queryClient = useQueryClient();
const toast = useToast();

const mutation = useMutation({
Expand All @@ -24,9 +22,6 @@ export function useApplicationMemberMutation() {
state: 'success',
message: '멤버 생성이 완료되었습니다.',
});
queryClient.invalidateQueries({
queryKey: MEMBER_QUERY_KEY.MEMBER(data),
});
},
});

Expand Down

0 comments on commit 7c1d0e2

Please sign in to comment.