import { cancelPayment } from '@_api/payment/paymentAPI'; import type { PaymentRetrieveResponse } from '@_api/payment/PaymentTypes'; import { cancelReservation, fetchDetailById, fetchSummaryByMember } from '@_api/reservation/reservationAPIV2'; import type { ReservationDetail, ReservationSummaryRetrieveResponse } from '@_api/reservation/reservationTypesV2'; import React, { useEffect, useState } from 'react'; import '../../css/my-reservation-v2.css'; const formatDisplayDateTime = (dateTime: any): string => { let date: Date; if (typeof dateTime === 'string') { // ISO 문자열 형식 처리 (LocalDateTime, OffsetDateTime 모두 포함) date = new Date(dateTime); } else if (typeof dateTime === 'number') { // Unix 타임스탬프(초) 형식 처리 date = new Date(dateTime * 1000); } else if (Array.isArray(dateTime) && dateTime.length >= 6) { // 배열 형식 처리: [year, month, day, hour, minute, second, nanosecond?] const year = dateTime[0]; const month = dateTime[1] - 1; // JS Date의 월은 0부터 시작 const day = dateTime[2]; const hour = dateTime[3]; const minute = dateTime[4]; const second = dateTime[5]; const millisecond = dateTime.length > 6 ? Math.floor(dateTime[6] / 1000000) : 0; date = new Date(year, month, day, hour, minute, second, millisecond); } else { return '유효하지 않은 날짜 형식'; } if (isNaN(date.getTime())) { return '유효하지 않은 날짜'; } const options: Intl.DateTimeFormatOptions = { year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric', hour12: true, second: 'numeric' }; return new Intl.DateTimeFormat('ko-KR', options).format(date); }; const formatCardDateTime = (dateStr: string, timeStr: string): string => { const date = new Date(`${dateStr}T${timeStr}`); const currentYear = new Date().getFullYear(); const reservationYear = date.getFullYear(); const days = ['일', '월', '화', '수', '목', '금', '토']; const dayOfWeek = days[date.getDay()]; const month = date.getMonth() + 1; const day = date.getDate(); let hours = date.getHours(); const minutes = date.getMinutes(); const ampm = hours >= 12 ? '오후' : '오전'; hours = hours % 12; hours = hours ? hours : 12; let datePart = ''; if (currentYear === reservationYear) { datePart = `${month}월 ${day}일(${dayOfWeek})`; } else { datePart = `${reservationYear}년 ${month}월 ${day}일(${dayOfWeek})`; } let timePart = `${ampm} ${hours}시`; if (minutes !== 0) { timePart += ` ${minutes}분`; } return `${datePart} ${timePart}`; }; // --- Cancellation View Component --- const CancellationView: React.FC<{ reservation: ReservationDetail; onCancelSubmit: (reason: string) => void; onBack: () => void; isCancelling: boolean; }> = ({ reservation, onCancelSubmit, onBack, isCancelling }) => { const [reason, setReason] = useState(''); const handleSubmit = () => { if (!reason.trim()) { alert('취소 사유를 입력해주세요.'); return; } onCancelSubmit(reason); }; return (

취소 정보 확인

테마: {reservation.themeName}

신청 일시: {formatDisplayDateTime(reservation.applicationDateTime)}

결제 금액: {reservation.payment.totalAmount.toLocaleString()}원