Skip to content

Commit

Permalink
fix: 버튼 클릭 이후 다시 목록 불러올 수 있게 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Dobbymin committed Nov 10, 2024
1 parent 062d12c commit 4fa136b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { applicantCheckIn } from "../applicant-check-in.api";
import { ApplicantCheckInResponse } from "../types";
import { useMutation } from "@tanstack/react-query";

export const usePutApplicantCheckIn = (id: number) => {
return useMutation({
mutationFn: () => applicantCheckIn(id),
export const usePutApplicantCheckIn = () => {
return useMutation<ApplicantCheckInResponse, Error, number>({
mutationFn: (id: number) => applicantCheckIn(id),
onSuccess: () => {
alert("체크인이 완료되었습니다.");
},
onError: (error) => {
onError: (error: Error) => {
console.error(error);
alert("체크인에 실패했습니다.");
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { getApplicantListPath } from "../applicant-list.api";
import { deleteInfo } from "../delete-info.api";
import { queryClient } from "@/shared";
import { useMutation } from "@tanstack/react-query";

export const useDeleteInfo = (id: number) => {
return useMutation({
mutationFn: () => deleteInfo(id),
onSuccess: () => {
alert("참가자 정보가 삭제되었습니다.");

queryClient.refetchQueries({ queryKey: [getApplicantListPath()] });
},
onError: (error) => {
console.error(error);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import { getApplicantListPath } from "../applicant-list.api";
import { putDepositCheck } from "../deposit-check";
import { DepositCheckResponse } from "../types";
import { queryClient } from "@/shared";
import { useMutation, UseMutationResult } from "@tanstack/react-query";

export const usePutDepositCheck = (id: number): UseMutationResult<DepositCheckResponse, Error, void> => {
return useMutation<DepositCheckResponse, Error, void>({
mutationFn: () => putDepositCheck(id),
onSuccess: () => {
alert("입금 완료로 상태가 변경되었습니다.");

queryClient.invalidateQueries({ queryKey: [getApplicantListPath()] });
},
onError: (error) => {
console.error("입금 완료 상태 변경에 실패했습니다.", error);

alert("입금 완료 상태 변경에 실패했습니다.");
},
});
Expand Down

0 comments on commit 4fa136b

Please sign in to comment.