|
1 | 1 | import { useTicketPatch, useTicketRetrive, useTicketUpdate } from "@apis/domains/tickets/queries";
|
2 | 2 | import Loading from "@components/commons/loading/Loading";
|
3 | 3 | import MetaTag from "@components/commons/meta/MetaTag";
|
| 4 | +import Toast from "@components/commons/toast/Toast"; |
4 | 5 | import { NAVIGATION_STATE } from "@constants/navigationState";
|
5 | 6 | import { useHeader, useModal, useToast } from "@hooks";
|
6 | 7 | import { useEffect, useState } from "react";
|
@@ -71,21 +72,69 @@ const TicketHolderList = () => {
|
71 | 72 | { performanceId: Number(performanceId) },
|
72 | 73 | filterList
|
73 | 74 | );
|
| 75 | + const { showToast, isToastVisible } = useToast(); |
| 76 | + const { openConfirm, closeConfirm } = useModal(); |
74 | 77 |
|
75 |
| - // 체크된 리스트 확인 |
76 | 78 | const [checkedBookingId, setCheckedBookingId] = useState<number[]>([]);
|
77 | 79 |
|
| 80 | + // 체크된 리스트 확인 |
78 | 81 | const handleBookingIdCheck = (bookingId: number) => {
|
79 | 82 | setCheckedBookingId((prev) =>
|
80 | 83 | prev.includes(bookingId) ? prev.filter((id) => id !== bookingId) : [...prev, bookingId]
|
81 | 84 | );
|
82 | 85 | };
|
83 | 86 |
|
| 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 | + |
84 | 132 | const actions = {
|
85 | 133 | PAYMENT: {
|
86 | 134 | text: "입금 처리하기",
|
87 | 135 | // TODO : 예매 확정 팝업
|
88 | 136 | action: () => {
|
| 137 | + handlePaymentFixBtn(); |
89 | 138 | setStatus("DEFAULT"), setFilterList({ scheduleNumber: [], bookingStatus: [] });
|
90 | 139 | },
|
91 | 140 | },
|
|
0 commit comments