Skip to content

Commit 3ecd641

Browse files
committed
feat: 입금 처리 api 연결
1 parent a9e1912 commit 3ecd641

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed

src/apis/domains/tickets/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export const putTicketUpdate = async (
5757
): Promise<SuccessResponseVoid | null> => {
5858
try {
5959
const response: AxiosResponse<ApiResponseType<SuccessResponseVoid>> = await put(
60-
"tickets",
60+
"tickets/update",
6161
formData
6262
);
6363

src/pages/ticketholderlist/TicketHolderList.tsx

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useTicketPatch, useTicketRetrive, useTicketUpdate } from "@apis/domains/tickets/queries";
22
import Loading from "@components/commons/loading/Loading";
33
import MetaTag from "@components/commons/meta/MetaTag";
4+
import Toast from "@components/commons/toast/Toast";
45
import { NAVIGATION_STATE } from "@constants/navigationState";
56
import { useHeader, useModal, useToast } from "@hooks";
67
import { useEffect, useState } from "react";
@@ -71,21 +72,69 @@ const TicketHolderList = () => {
7172
{ performanceId: Number(performanceId) },
7273
filterList
7374
);
75+
const { showToast, isToastVisible } = useToast();
76+
const { openConfirm, closeConfirm } = useModal();
7477

75-
// 체크된 리스트 확인
7678
const [checkedBookingId, setCheckedBookingId] = useState<number[]>([]);
7779

80+
// 체크된 리스트 확인
7881
const handleBookingIdCheck = (bookingId: number) => {
7982
setCheckedBookingId((prev) =>
8083
prev.includes(bookingId) ? prev.filter((id) => id !== bookingId) : [...prev, bookingId]
8184
);
8285
};
8386

87+
const {
88+
mutate: updateMutate,
89+
mutateAsync: updateMutateAsync,
90+
isPending: updateIsPending,
91+
} = useTicketUpdate();
92+
93+
const handlePaymentFixAxiosFunc = () => {
94+
if (updateIsPending) {
95+
return;
96+
}
97+
// 예매 완료 PUT API 요청
98+
// paymentData에 accountHolder, accountNumber, bankName 제거
99+
const filteredPaymentData = paymentData.map(
100+
({ bankName, accountNumber, accountHolder, ...rest }) => ({
101+
...rest,
102+
bookingStatus: checkedBookingId.includes(rest.bookingId)
103+
? "BOOKING_CONFIRMED"
104+
: rest.bookingStatus,
105+
})
106+
);
107+
108+
updateMutate({
109+
performanceId: Number(performanceId),
110+
performanceTitle: data?.performanceTitle,
111+
totalScheduleCount: data?.totalScheduleCount,
112+
bookingList: filteredPaymentData,
113+
});
114+
closeConfirm();
115+
showToast();
116+
setTimeout(() => {
117+
// window.location.reload();
118+
}, 1000);
119+
};
120+
121+
const handlePaymentFixBtn = () => {
122+
openConfirm({
123+
title: "입금 처리시 예매확정 문자가 발송돼요.",
124+
subTitle: "예매자에게 입금이 확인되었음을 알려드릴게요!",
125+
okText: "입금 처리하기",
126+
noText: "아니요",
127+
okCallback: handlePaymentFixAxiosFunc,
128+
noCallback: closeConfirm,
129+
});
130+
};
131+
84132
const actions = {
85133
PAYMENT: {
86134
text: "입금 처리하기",
87135
// TODO : 예매 확정 팝업
88136
action: () => {
137+
handlePaymentFixBtn();
89138
setStatus("DEFAULT"), setFilterList({ scheduleNumber: [], bookingStatus: [] });
90139
},
91140
},

0 commit comments

Comments
 (0)