Skip to content

Commit

Permalink
feat: onSuccessCallBack 을 없앰
Browse files Browse the repository at this point in the history
  • Loading branch information
pakxe committed Aug 21, 2024
1 parent ad1f45a commit c5f2f6f
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions client/src/hooks/queries/useRequestPutBillAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,18 @@ interface PutBillActionMutationProps {
actionId: number;
title: string;
price: number;
onSuccessCallback?: () => void; // 콜백 함수 타입을 정의
}

const useRequestPutBillAction = () => {
const eventId = getEventIdByUrl();
const queryClient = useQueryClient();

return useMutation({
mutationFn: async ({actionId, title, price}: PutBillActionMutationProps) => {
const response = await requestPutBillAction({eventId, actionId, title, price});
return response; // response를 반환하여 onSuccess에서 접근할 수 있게 함
},
onSuccess: (data, variables) => {
mutationFn: ({actionId, title, price}: PutBillActionMutationProps) =>
requestPutBillAction({eventId, actionId, title, price}),
onSuccess: () => {
queryClient.invalidateQueries({queryKey: [QUERY_KEYS.stepList]});
queryClient.invalidateQueries({queryKey: [QUERY_KEYS.memberReport]});

// 콜백 함수가 전달되었다면 실행
if (variables.onSuccessCallback) {
variables.onSuccessCallback();
}
},
});
};
Expand Down

0 comments on commit c5f2f6f

Please sign in to comment.