From fd4db6241cbea85061a1ed963f2fef86b2821a42 Mon Sep 17 00:00:00 2001 From: Sinji Date: Tue, 3 Dec 2024 02:15:46 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=ED=99=98=EB=B6=88=20=EC=B2=98=EB=A6=AC?= =?UTF-8?q?=20api=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/domains/tickets/api.ts | 27 +++----- src/apis/domains/tickets/queries.ts | 9 +-- src/assets/svgs/index.ts | 68 ------------------- src/assets/svgs/index.tsx | 6 +- .../ticketholderlist/TicketHolderList.tsx | 67 ++++++++++++++++-- 5 files changed, 81 insertions(+), 96 deletions(-) delete mode 100644 src/assets/svgs/index.ts diff --git a/src/apis/domains/tickets/api.ts b/src/apis/domains/tickets/api.ts index 226d56ef..1590cc38 100644 --- a/src/apis/domains/tickets/api.ts +++ b/src/apis/domains/tickets/api.ts @@ -37,17 +37,11 @@ export const getTicketRetrieve = async ( } }; +type SuccessResponseVoid = components["schemas"]["SuccessResponseVoid"]; + // 예매자 입급 여부 수정 API (PUT) -/* -export interface putTicketReq { - performanceId: number; - performanceTitle: string; - totalScheduleCoun: number; - bookingList: BookingListProps[]; -} -*/ + export type TicketUpdateRequest = components["schemas"]["TicketUpdateRequest"]; -type SuccessResponseVoid = components["schemas"]["SuccessResponseVoid"]; //async 함수는 항상 promise로 감싸서 값을 리턴한다. //즉, 비동기 함수의 값을 사용하려면 추후 await이나 then 을 사용해야 한다던데.. @@ -68,18 +62,19 @@ export const putTicketUpdate = async ( } }; -// 예매자 취소 API (PATCH) -//이거 타입 잘못되었을 수도..? bookingList 가 number를 담은 배열로 되어 있는데, 실제로는 아니었음 -//export type TicketDeleteRequest = components["schemas"]["TicketDeleteRequest"]; +// 예매자 환불처리 (PUT) + +export type TicketRefundRequest = components["schemas"]["TicketRefundRequest"]; -export const patchTicketCancel = async ( - formData: PatchFormDataProps +export const putTicketRefund = async ( + formData: TicketRefundRequest ): Promise => { try { - const response: AxiosResponse> = await patch( - "tickets", + const response: AxiosResponse> = await put( + "tickets/refund", formData ); + return response.data.data; } catch (error) { console.log("error", error); diff --git a/src/apis/domains/tickets/queries.ts b/src/apis/domains/tickets/queries.ts index 51c1538f..1fbb3c29 100644 --- a/src/apis/domains/tickets/queries.ts +++ b/src/apis/domains/tickets/queries.ts @@ -3,8 +3,9 @@ import { PatchFormDataProps } from "@typings/deleteBookerFormatProps"; import { getTicketReq, getTicketRetrieve, - patchTicketCancel, + putTicketRefund, putTicketUpdate, + TicketRefundRequest, TicketUpdateRequest, } from "./api"; @@ -37,12 +38,12 @@ export const useTicketUpdate = () => { }); }; -// 예매자를 취소하는 API (PATCH)를 위한 쿼리 작성 -export const useTicketPatch = () => { +// 예매자 환불 여부 수정 API (PUT)를 위한 쿼리 작성 +export const useTicketRefund = () => { const queryClient = new QueryClient(); return useMutation({ - mutationFn: (formData: PatchFormDataProps) => patchTicketCancel(formData), + mutationFn: (formData: TicketRefundRequest) => putTicketRefund(formData), onSuccess: (res) => { queryClient.invalidateQueries({ queryKey: [QUERY_KEY.LIST, BOOKING_QUERY_KEY.BOOKING_LIST] }); queryClient.refetchQueries({ queryKey: [QUERY_KEY.LIST, BOOKING_QUERY_KEY.BOOKING_LIST] }); diff --git a/src/assets/svgs/index.ts b/src/assets/svgs/index.ts deleted file mode 100644 index d986239c..00000000 --- a/src/assets/svgs/index.ts +++ /dev/null @@ -1,68 +0,0 @@ -export { default as BannerBasic } from "./BannerBasic"; -export { default as BeatMapMarker } from "./BeatMapMarker"; -export { default as BtnFloating } from "./BtnFloating"; -export { default as BtnModalDelete } from "./BtnModalDelete"; -export { default as ButtonDelete24 } from "./ButtonDelete24"; -export { default as CarouselPartInactive } from "./CarouselPartInactive"; -export { default as Empty } from "./Empty"; -export { default as IcomCopy } from "./IcomCopy"; -export { default as IconArrowLeft } from "./IconArrowLeft"; -export { default as IconArrowRight } from "./IconArrowRight"; -export { default as IconArrowDown } from "./IconArrowDown"; -export { default as IconArrowUp } from "./IconArrowUp"; -export { default as IconBnk } from "./IconBnk"; -export { default as IconCalendar } from "./IconCalendar"; -export { default as IconCamera } from "./IconCamera"; -export { default as IconCheckboxDisabledOn } from "./IconCheckboxDisabledOn"; -export { default as IconCheckboxSelectedOn } from "./IconCheckboxSelectedOn"; -export { default as IconCheckboxUnselectedOn } from "./IconCheckboxUnselectedOn"; -export { default as IconChecked } from "./IconChecked"; -export { default as IconCheck } from "./IconCheck"; -export { default as IconChevronBack } from "./IconChevronBack"; -export { default as IconEmpty } from "./IconEmpty"; -export { default as IconEyeOff } from "./IconEyeOff"; -export { default as IconEyeOn } from "./IconEyeOn"; -export { default as IconFooterLogo } from "./IconFooterLogo"; -export { default as IconHanna } from "./IconHanna"; -export { default as IconIbk } from "./IconIbk"; -export { default as IconIm } from "./IconIm"; -export { default as IconImg } from "./IconImg"; -export { default as IconKabank } from "./IconKabank"; -export { default as IconKb } from "./IconKb"; -export { default as IconLargeBand } from "./IconLargeBand"; -export { default as IconLargeDance } from "./IconLargeDance"; -export { default as IconLargeEtc } from "./IconLargeEtc"; -export { default as IconLargeMusical } from "./IconLargeMusical"; -export { default as IconLogo } from "./IconLogo"; -export { default as IconMinus } from "./IconMinus"; -export { default as IconNonghyup } from "./IconNonghyup"; -export { default as IconPhotoDelete } from "./IconPhotoDelete"; -export { default as IconPlus } from "./IconPlus"; -export { default as IconProfile } from "./IconProfile"; -export { default as IconRoleAdd } from "./IconRoleAdd"; -export { default as IconSaemauel } from "./IconSaemauel"; -export { default as IconSc } from "./IconSc"; -export { default as IconSearch } from "./IconSearch"; -export { default as IconShinhan } from "./IconShinhan"; -export { default as IconShinhyup } from "./IconShinhyup"; -export { default as IconSmallBand } from "./IconSmallBand"; -export { default as IconSmallDance } from "./IconSmallDance"; -export { default as IconSmallEtc } from "./IconSmallEtc"; -export { default as IconSmallMusical } from "./IconSmallMusical"; -export { default as IconSoohyup } from "./IconSoohyup"; -export { default as IconTextfiedlDelete } from "./IconTextfiedlDelete"; -export { default as IconTime } from "./IconTime"; -export { default as IconToggleOff } from "./IconToggleOff"; -export { default as IconToggleOn } from "./IconToggleOn"; -export { default as IconToss } from "./IconToss"; -export { default as IconWoochaegook } from "./IconWoochaegook"; -export { default as IconWoori } from "./IconWoori"; -export { default as IconXButton } from "./IconXButton"; -export { default as IcDelete } from "./IcDelete"; -export { default as IcHamburgar } from "./IcHamburgar"; -export { default as IcOutlinePlace } from "./IcOutlinePlace"; -export { default as KakaoMapArrow } from "./KakaoMapArrow"; -export { default as NotFoundAsset } from "./NotFoundAsset"; -export { default as Subtract } from "./Subtract"; -export { default as Switch } from "./Switch"; -export { default as Union } from "./Union"; diff --git a/src/assets/svgs/index.tsx b/src/assets/svgs/index.tsx index a9e4be0a..b926ac37 100644 --- a/src/assets/svgs/index.tsx +++ b/src/assets/svgs/index.tsx @@ -1,4 +1,6 @@ export { default as BannerBasic } from "./BannerBasic"; +export { default as BeatMapMarker } from "./BeatMapMarker"; +export { default as BtnFilter } from "./BtnFilter"; export { default as BtnFloating } from "./BtnFloating"; export { default as BtnModalDelete } from "./BtnModalDelete"; export { default as ButtonDelete24 } from "./ButtonDelete24"; @@ -60,10 +62,10 @@ export { default as IconWoochaegook } from "./IconWoochaegook"; export { default as IconWoori } from "./IconWoori"; export { default as IconXButton } from "./IconXButton"; export { default as IcOutlinePlace } from "./IcOutlinePlace"; -export { default as KakaoMapArrow } from "./KakaoMapArrow"; export { default as IcRefresh } from "./IcRefresh"; +export { default as KakaoMapArrow } from "./KakaoMapArrow"; export { default as NotFoundAsset } from "./NotFoundAsset"; export { default as SelectionControlCheckboxSelectedOff } from "./SelectionControlCheckboxSelectedOff"; export { default as Subtract } from "./Subtract"; export { default as Switch } from "./Switch"; -export { default as Union } from "./Union"; +export { default as Union } from "./Union"; \ No newline at end of file diff --git a/src/pages/ticketholderlist/TicketHolderList.tsx b/src/pages/ticketholderlist/TicketHolderList.tsx index 92e7c624..7dd86c7a 100644 --- a/src/pages/ticketholderlist/TicketHolderList.tsx +++ b/src/pages/ticketholderlist/TicketHolderList.tsx @@ -1,4 +1,9 @@ -import { useTicketPatch, useTicketRetrive, useTicketUpdate } from "@apis/domains/tickets/queries"; +import { + useTicketPatch, + useTicketRefund, + useTicketRetrive, + useTicketUpdate, +} from "@apis/domains/tickets/queries"; import Loading from "@components/commons/loading/Loading"; import MetaTag from "@components/commons/meta/MetaTag"; import Toast from "@components/commons/toast/Toast"; @@ -114,7 +119,7 @@ const TicketHolderList = () => { closeConfirm(); showToast(); setTimeout(() => { - // window.location.reload(); + window.location.reload(); }, 1000); }; @@ -124,25 +129,75 @@ const TicketHolderList = () => { subTitle: "예매자에게 입금이 확인되었음을 알려드릴게요!", okText: "입금 처리하기", noText: "아니요", - okCallback: handlePaymentFixAxiosFunc, + okCallback: () => { + handlePaymentFixAxiosFunc(); + // 혹시 테스트 과정에서 로그 확인을 위해 새로고침을 지운다면 아래 주석 해제 + // setStatus("DEFAULT"); + // setFilterList({ scheduleNumber: [], bookingStatus: [] }); + // setCheckedBookingId([]); + }, noCallback: closeConfirm, }); }; + // 환불 요청 + + const { + mutate: refundMutate, + mutateAsync: refundMutateAsync, + isPending: refundIsPending, + } = useTicketRefund(); + + const handlePaymentRefundBtn = () => { + openConfirm({ + title: "환불 처리 하시겠어요?", + subTitle: "예매자에게 환불 금액을 보낸 뒤 처리해 주세요.", + okText: "환불 처리하기", + noText: "아니요", + okCallback: () => { + handlePaymentRefundAxiosFunc(); + // 혹시 테스트 과정에서 로그 확인을 위해 새로고침을 지운다면 아래 주석 해제 + // setStatus("DEFAULT"); + // setFilterList({ scheduleNumber: [], bookingStatus: [] }); + // setCheckedBookingId([]); + }, + noCallback: closeConfirm, + }); + }; + + const handlePaymentRefundAxiosFunc = () => { + if (refundIsPending) { + return; + } + // 환불 요청 PUT API 요청 + // bookingId만 전달 + const filteredPaymentData = paymentData.map(({ bookingId }) => ({ + bookingId: checkedBookingId.includes(bookingId) && bookingId, + })); + + refundMutate({ + performanceId: Number(performanceId), + bookingList: filteredPaymentData, + }); + closeConfirm(); + showToast(); + setTimeout(() => { + window.location.reload(); + }, 1000); + }; + const actions = { PAYMENT: { text: "입금 처리하기", - // TODO : 예매 확정 팝업 action: () => { handlePaymentFixBtn(); - setStatus("DEFAULT"), setFilterList({ scheduleNumber: [], bookingStatus: [] }); }, }, REFUND: { text: "환불 처리하기", // TODO : 환불 처리 팝업 action: () => { - setStatus("DEFAULT"), setFilterList({ scheduleNumber: [], bookingStatus: [] }); + handlePaymentRefundBtn(); }, }, DELETE: {