Skip to content
Merged
6 changes: 4 additions & 2 deletions src/constants/bookingStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ export type BookingStatus = (typeof BOOKING_STATUS)[keyof typeof BOOKING_STATUS]

export const bookingStatusText: Record<BookingStatus, string> = {
[BOOKING_STATUS.CHECKING_PAYMENT]: "입금 확인 중",
[BOOKING_STATUS.BOOKING_CONFIRMED]: "입금 완료",
[BOOKING_STATUS.BOOKING_CONFIRMED]: "예매 확정",
[BOOKING_STATUS.BOOKING_CANCELLED]: "취소 완료",
[BOOKING_STATUS.BOOKING_DELETED]: "취소 완료",
[BOOKING_STATUS.REFUND_REQUESTED]: "환불 요청",
[BOOKING_STATUS.REFUND_REQUESTED]: "환불 접수 완료",
};

export const DELETABLE_BOOKING_STATUSES = [BOOKING_STATUS.BOOKING_CANCELLED] as const;

export type bookingStatusTypes = keyof typeof bookingStatusText;

export interface DefaultDepositProps {
Expand Down
6 changes: 3 additions & 3 deletions src/constants/convertingBookingStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ type PaymentType =
export const convertingBookingStatus = (_bookingStatus: PaymentType): string => {
switch (_bookingStatus) {
case "CHECKING_PAYMENT":
return "미입금";
return "입금 확인 필요";
case "BOOKING_CONFIRMED":
return "입금 완료";
return "예매 확정";
case "BOOKING_CANCELLED":
return "취소 완료";
case "REFUND_REQUESTED":
return "환불 요청";
return "환불 처리 필요";
default:
throw new Error("알 수 없는 상태입니다.");
}
Expand Down
28 changes: 16 additions & 12 deletions src/hooks/useCancelBooking.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ interface CancelRequestProps {
accountHolder?: string;
}

const isRefundRequest = (requestData: CancelRequestProps) =>
Boolean(requestData.bankName || requestData.accountNumber || requestData.accountHolder);

Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
export const useCancelBooking = (name?: string, phone?: string, password?: string) => {
Comment on lines 13 to 17

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요이~

const { openAlert, openConfirm, closeConfirm } = useModal();
const [toastMessage, setToastMessage] = useState<string | null>(null);
Expand All @@ -28,15 +31,12 @@ export const useCancelBooking = (name?: string, phone?: string, password?: strin
phone?: string,
password?: string
) => {
const mutation =
requestData.bankName || requestData.accountNumber || requestData.accountHolder
? refundMutation
: cancelMutation;
const shouldRequestRefund = isRefundRequest(requestData);
const mutation = shouldRequestRefund ? refundMutation : cancelMutation;

const toastMessage =
requestData.bankName || requestData.accountNumber || requestData.accountHolder
? "메이커에게 환불을 요청했어요."
: "예매 취소가 완료됐어요.";
const toastMessage = shouldRequestRefund
? "메이커에게 환불을 요청했어요."
: "예매 취소가 완료됐어요.";

mutation.mutate(requestData, {
onSuccess: () => {
Expand All @@ -61,14 +61,18 @@ export const useCancelBooking = (name?: string, phone?: string, password?: strin
};

const confirmCancelAction = (requestData: CancelRequestProps) => {
const shouldRequestRefund = isRefundRequest(requestData);

openConfirm({
title: "예매를 정말 취소하시겠어요?",
subTitle: "취소한 예매내역은 복구할 수 없어요.",
okText: "취소할게요",
title: shouldRequestRefund ? "환불을 요청할까요?" : "예매를 취소할까요?",
subTitle: shouldRequestRefund
? "관리자가 확인한 후 환불을 진행해요."
: "예매가 바로 취소되고 좌석이 반환돼요.",
okText: shouldRequestRefund ? "환불 요청" : "예매 취소",
okCallback: () => {
handleCancelRequest(requestData, name, phone, password);
},
noText: "아니요",
noText: "돌아가기",
noCallback: closeConfirm,
});
};
Expand Down
2 changes: 2 additions & 0 deletions src/pages/cancel/Cancel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,14 @@ const Cancel = () => {
<S.RadioWrapper>
<RadioButton
label="입금 전이에요"
description="예매가 바로 취소돼요"
value={1}
checked={isDeposit === false}
onChange={() => setIsDeposit(false)}
/>
<RadioButton
label="입금했어요"
description="환불을 요청해요"
value={0}
checked={isDeposit === true}
onChange={() => setIsDeposit(true)}
Expand Down
14 changes: 13 additions & 1 deletion src/pages/cancel/components/select/RadioButton.styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const ButtonBox = styled.button<{
align-items: center;
box-sizing: border-box;
width: 32.7rem;
height: 6rem;
min-height: 7.2rem;
padding: 1.2rem calc(1.6rem - 2px);

color: ${({ $variant, theme }) =>
Expand All @@ -25,3 +25,15 @@ export const ButtonBox = styled.button<{
right: calc(1rem - 2px);
}
`;

export const LabelWrapper = styled.span`
display: flex;
flex-direction: column;
gap: 0.4rem;
align-items: flex-start;
`;

export const Description = styled.span`
color: ${({ theme }) => theme.colors.gray_300};
${({ theme }) => theme.fonts["caption1-medi"]};
`;
8 changes: 6 additions & 2 deletions src/pages/cancel/components/select/RadioButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@ import * as S from "./RadioButton.styled";

interface RadioButtonProps {
label: string;
description?: string;
value: number;
checked: boolean;
onChange: (value: number) => void;
}

const RadioButton = ({ label, value, checked, onChange }: RadioButtonProps) => {
const RadioButton = ({ label, description, value, checked, onChange }: RadioButtonProps) => {
const variant = checked ? "selected" : "initial";

return (
<S.ButtonBox $variant={variant} onClick={() => onChange(value)}>
<span>{label}</span>
<S.LabelWrapper>
<span>{label}</span>
{description && <S.Description>{description}</S.Description>}
</S.LabelWrapper>
{checked ? <IcRadioSelected width={32} /> : <IcRadioUnselected width={32} />}
</S.ButtonBox>
);
Expand Down
9 changes: 9 additions & 0 deletions src/pages/test/modalTest/BankAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ const BankAccount = ({ bankName, number, accountName, accountNumber, price }: Ba
<StyledIconCopy onClick={() => handleCopyClipBoard(number)} />
</Box>
</Container>
<PaymentNotice>
입금 전이라면 안내된 계좌로 입금해 주세요. 이미 입금했다면 관리자 확인을 기다려 주세요.
</PaymentNotice>
<BtnWrapper>
<Button size="small" variant="gray" onClick={closeModal}>
닫기
Expand Down Expand Up @@ -71,6 +74,12 @@ const Container = styled.div`
width: 100%;
`;

const PaymentNotice = styled.p`
color: ${({ theme }) => theme.colors.gray_300};
text-align: center;
${({ theme }) => theme.fonts["caption2-medi"]};
`;

const Text = styled.p`
text-align: center;
${({ theme }) => theme.fonts.heading4};
Expand Down
3 changes: 2 additions & 1 deletion src/pages/ticketholderlist/TicketHolderList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import SelectedChips from "./components/selectedChips/SelectedChips";
import { convertingBookingStatus } from "@constants/convertingBookingStatus";
import { IconCheck } from "@assets/svgs";
import Toast from "@components/commons/toast/Toast";
import { DELETABLE_BOOKING_STATUSES } from "@constants/bookingStatus";
import NonExistent from "./components/nonExistent/NonExistent.";
import { getUA, isChrome } from "react-device-detect";
import { useToastHandler } from "@hooks";
Expand Down Expand Up @@ -296,7 +297,7 @@ const TicketHolderList = () => {
case "DELETE":
setFilterList({
scheduleNumber: [],
bookingStatus: ["CHECKING_PAYMENT", "BOOKING_CONFIRMED", "REFUND_REQUESTED"],
bookingStatus: [...DELETABLE_BOOKING_STATUSES],
});
break;
default:
Expand Down
Loading