import { useEffect, useState } from 'react'; import { useLocation } from 'react-router'; import { PATHS } from '@/shared/constants/paths'; import { useNavigate } from '@/shared/lib/hooks/use-navigate'; import { useEscrowDetailMutation } from '@/entities/transaction/api/use-escrow-detail-mutation'; import { ImportantInfoSection } from '@/entities/transaction/ui/section/important-info-section'; import { EscrowInfoSection } from '@/entities/transaction/ui/section/escrow-info-section'; import { PaymentInfoSection } from '@/entities/transaction/ui/section/payment-info-section'; import { TransactionInfoSection } from '@/entities/transaction/ui/section/transaction-info-section'; import { SettlementInfoSection } from '@/entities/transaction/ui/section/settlement-info-section'; import { HeaderType } from '@/entities/common/model/types'; import { TransactionCategory, EscrowDetailParams, DetailResponse, ImportantInfo, EscrowInfo, PaymentInfo, TransactionInfo, SettlementInfo, InfoSectionKeys, MerchantInfo, AmountInfo } from '@/entities/transaction/model/types'; import { useSetOnBack, useSetHeaderTitle, useSetHeaderType, useSetFooterMode } from '@/widgets/sub-layout/use-sub-layout'; import { EscrowMailResendBottomSheet } from '@/entities/transaction/ui/escrow-mail-resend-bottom-sheet'; import { useEscrowMailResendMutation } from '@/entities/transaction/api/use-escrow-mail-resend-mutation'; import { MerchantInfoSection } from '@/entities/transaction/ui/section/merchant-info-section'; import { AmountInfoSection } from '@/entities/transaction/ui/section/amount-info-section'; export const EscrowDetailPage = () => { const { navigate } = useNavigate(); const location = useLocation(); const paramTid = location?.state.tid; const serviceCode = location?.state.serviceCode; const [amountInfo, setAmountInfo] = useState(); const [importantInfo, setImportantInfo] = useState(); const [escrowInfo, setEscrowInfo] = useState(); const [paymentInfo, setPaymentInfo] = useState(); const [transactionInfo, setTransactionInfo] = useState(); const [settlementInfo, setSettlementInfo] = useState(); const [merchantInfo, setMerchantInfo] = useState(); const [showAmountInfo, setShowAmountInfo] = useState(false); const [showImportantInfo, setShowImportantInfo] = useState(false); const [showEscroInfo, setShowEscroInfo] = useState(false); const [showPaymentInfo, setShowPaymentInfo] = useState(false); const [showTransactionInfo, setShowTransactionInfo] = useState(false); const [showSettlementInfo, setShowSettlementInfo] = useState(false); const [showMerchantInfo, setShowMerchantInfo] = useState(false); const [bottomSheetOn, setBottomSheetOn] = useState(false); const [orderNumber, setOrderNumber] = useState(); const [tid, setTid] = useState(paramTid); useSetHeaderTitle('에스크로 상세'); useSetHeaderType(HeaderType.RightClose); useSetOnBack(() => { navigate(PATHS.transaction.escrow.list); }); useSetFooterMode(false); const { mutateAsync: escrowDetail } = useEscrowDetailMutation(); const { mutateAsync: escrowMailResend } = useEscrowMailResendMutation() const callDetail = () => { let escroDetailParams: EscrowDetailParams = { tid: tid || paramTid, }; escrowDetail(escroDetailParams).then((rs: DetailResponse) => { setAmountInfo(rs.paymentInfo || {}); setImportantInfo(rs.importantInfo || {}); setEscrowInfo(rs.escrowInfo || {}); setPaymentInfo(rs.paymentInfo || {}); setTransactionInfo(rs.transactionInfo || {}); setSettlementInfo(rs.settlementInfo || {}); setMerchantInfo(rs.merchantInfo || {}); setOrderNumber(rs.importantInfo?.orderNumber); setTid(rs.importantInfo?.tid); }); }; useEffect(() => { callDetail(); }, []); const onClickToShowMailResend = () => { setBottomSheetOn(true); }; const callMailResend = () => { let params = { orderNumber: orderNumber, tid: tid, }; escrowMailResend(params).then((rs: any) => { console.log(rs); }); }; const onClickToOpenInfo = (infoSectionKey: InfoSectionKeys) => { if(infoSectionKey === InfoSectionKeys.Amount){ setShowAmountInfo(!showAmountInfo); } else if(infoSectionKey === InfoSectionKeys.Important){ setShowImportantInfo(!showImportantInfo); } else if(infoSectionKey === InfoSectionKeys.Escrow){ setShowEscroInfo(!showEscroInfo); } else if(infoSectionKey === InfoSectionKeys.Payment){ setShowPaymentInfo(!showPaymentInfo); } else if(infoSectionKey === InfoSectionKeys.Transaction){ setShowTransactionInfo(!showTransactionInfo); } else if(infoSectionKey === InfoSectionKeys.Settlement){ setShowSettlementInfo(!showSettlementInfo); } else if(infoSectionKey === InfoSectionKeys.Merchant){ setShowMerchantInfo(!showMerchantInfo); } }; return ( <>
onClickToOpenInfo(infoSectionKey) } >
onClickToOpenInfo(infoSectionKey) } >
onClickToOpenInfo(infoSectionKey) } >
onClickToOpenInfo(infoSectionKey) } >
onClickToOpenInfo(infoSectionKey) } > onClickToOpenInfo(infoSectionKey) } >
); };