import { NumericFormat } from 'react-number-format'; import { PATHS } from '@/shared/constants/paths'; import { useNavigate } from '@/shared/lib/hooks/use-navigate'; import { ListItemProps, TransactionCategory } from '../model/types'; import moment from 'moment'; export const ListItem = ({ transactionCategory, tid, mid, stateDate, stateCode, stateName, installmentMonth, serviceCode, serviceName, serviceDetailName, goodsAmount, id, amount, customerName, issueNumber, issueStatus, paymentMethod, processResult, transactionDateTime, transactionAmount, deliveryStatus, settlementStatus, cancelStatus, billKey, orderNumber }: ListItemProps) => { const { navigate } = useNavigate(); const getItemClass = () => { let rs = ''; if(stateCode === '0'){ rs = ''; } else if(stateCode === '1'){ rs = 'approved'; } else if(stateCode === '2'){ rs = 'refund'; } return rs; }; const getDotClass = (str?: string) => { let rs = ''; if(stateCode === '0'){ rs = ''; } else if(stateCode === '1'){ rs = 'blue'; } else if(stateCode === '2'){ rs = 'gray'; } return rs; }; const onClickToNavigate = () => { if(transactionCategory === TransactionCategory.AllTransaction){ navigate(PATHS.transaction.allTransaction.detail, { state: { tid: tid, serviceCode: serviceCode } }); } else if(transactionCategory === TransactionCategory.CashReceipt){ navigate(PATHS.transaction.cashReceipt.detail, { state: { issueNumber: issueNumber } }); } else if(transactionCategory === TransactionCategory.Escrow){ navigate(PATHS.transaction.escrow.detail, { state: { issueNumber: issueNumber } }); } else if(transactionCategory === TransactionCategory.Billing){ navigate(PATHS.transaction.billing.detail, { state: { billKey: billKey } }); } else{ alert('pageType 이 존재하지 않습니다.'); } }; const getTime = () => { let timeStr = ''; if(transactionCategory === TransactionCategory.AllTransaction){ let time = stateDate?.substring(8, 12); timeStr = time?.substring(0, 2) + ':' + time?.substring(2, 4); } else{ timeStr = moment(transactionDateTime).format('HH:mm'); } return timeStr }; const getTitle = () => { let str = ''; if(transactionCategory === TransactionCategory.AllTransaction){ str = `${serviceName}(${serviceDetailName})`; } else if(transactionCategory === TransactionCategory.CashReceipt){ str = `${customerName}(${issueNumber})` } else if(transactionCategory === TransactionCategory.Escrow){ str = `${customerName}(${issueNumber})` } else if(transactionCategory === TransactionCategory.Billing){ str = `${billKey}` } return str; }; const getDetail = () => { let rs = []; if(transactionCategory === TransactionCategory.AllTransaction){ rs.push( <> { getTime() } | { stateName } | { mid } > ); } else if(transactionCategory === TransactionCategory.CashReceipt){ rs.push( <> { getTime() } | { issueStatus } | { paymentMethod } | { processResult } > ); } else if(transactionCategory === TransactionCategory.Escrow){ rs.push( <> { getTime() } | { deliveryStatus } | { settlementStatus } | { cancelStatus } > ); } else if(transactionCategory === TransactionCategory.Billing){ rs.push( <> { getTime() } | { processResult } | { paymentMethod } > ); } return rs; }; return ( <>