통합거래조회 UI api

This commit is contained in:
focp212@naver.com
2025-09-11 13:40:21 +09:00
parent 409a711b9a
commit 1b4af7a82f
27 changed files with 1056 additions and 390 deletions

View File

@@ -1,16 +1,102 @@
import moment from 'moment';
import { motion } from 'framer-motion';
import { DetailArrow } from '../detail-arrow';
import { InfoWrapKeys, DetailInfoProps } from '../../model/types';
import { InfoWrapKeys, DetailInfoProps, TransactionCategory } from '../../model/types';
import { NumericFormat } from 'react-number-format';
export const TransactionInfoWrap = ({
transactionCategory,
transactionInfo,
serviceCode,
show,
onClickToShowInfo
}: DetailInfoProps) => {
const subItems: Record<string, Record<string, string>> = {
buyerName: {name: '구매자명', type: 'string'},
email: {name: '이메일', type: 'string'},
phoneNumber: {name: '전화번호', type: 'string'},
cancelReason: {name: '취소사유', type: 'string'},
cancelRequestor: {name: '취소요청자', type: 'string'},
partialCancel: {name: '부분취소', type: 'string'},
cashReceiptIssue: {name: '현금영수증발행', type: 'string'},
};
const showSubItems: Record<string, Array<string>> = {
// 신용카드
'01': ['buyerName', 'email', 'phoneNumber', 'cancelReason',
'cancelRequestor', 'partialCancel'],
// 계좌이체
'02': ['buyerName', 'email', 'phoneNumber', 'cancelReason',
'cancelRequestor', 'partialCancel', 'cashReceiptIssue'],
// 가상계좌
'03': ['buyerName', 'email', 'phoneNumber', 'cancelReason',
'cancelRequestor', 'partialCancel', 'cashReceiptIssue'],
// 휴대폰
'04': ['buyerName', 'email', 'phoneNumber', 'cancelReason',
'cancelRequestor'],
// 계좌간편결제
'26': ['buyerName', 'email', 'phoneNumber', 'cancelReason',
'cancelRequestor', 'partialCancel', 'cashReceiptIssue'],
// SSG머니
'21': ['buyerName', 'email', 'phoneNumber', 'cancelReason',
'cancelRequestor'],
// SSG은행계좌
'24': ['buyerName', 'email', 'phoneNumber', 'cancelReason',
'cancelRequestor'],
// 문화상품권
'14': ['buyerName', 'email', 'phoneNumber', 'cancelReason',
'cancelRequestor'],
// 티머니페이
'31': ['buyerName', 'email', 'phoneNumber', 'cancelReason',
'cancelRequestor'],
};
const checkValue = (val: any) => {
return (!!val || val === 0);
};
let newTransactionInfo: Record<string, any> | undefined = transactionInfo;
const subLi = () => {
let rs = [];
if(!!newTransactionInfo && !!serviceCode && !!showSubItems[serviceCode]){
for(let i=0;i<showSubItems[serviceCode].length;i++){
let k = showSubItems[serviceCode][i];
if(!!k){
rs.push(
<li
key={`key-important-item-${i}`}
className="kv-row"
>
<span className="k">·&nbsp;&nbsp;{ subItems[k]?.name }</span>
<span className="v">
{ (checkValue(newTransactionInfo[k]) && subItems[k]?.type === 'string') &&
newTransactionInfo[k]
}
{ (checkValue(newTransactionInfo[k]) && subItems[k]?.type === 'number') &&
<NumericFormat
value={ newTransactionInfo[k] }
thousandSeparator
displayType="text"
suffix='원'
></NumericFormat>
}
{ (checkValue(newTransactionInfo[k]) && subItems[k]?.type === 'date') &&
moment(newTransactionInfo[k]).format('YYYY.MM.DD')
}
</span>
</li>
);
}
}
}
return rs;
};
const variants = {
hidden: { height: 0, padding: 0, display: 'none' },
visible: { height: 'auto', paddingTop: '12px', display: 'block' },
hidden: { height: 0, display: 'none' },
visible: { height: 'auto', display: 'block' },
};
const onClickToSetShowInfo = () => {
@@ -35,14 +121,22 @@ export const TransactionInfoWrap = ({
variants={ variants }
transition={{ duration: 0.3 }}
>
<li className="kv-row">
<span className="k"></span>
<span className="v">NICE PAY</span>
</li>
<li className="kv-row">
<span className="k"></span>
<span className="v">123-45-67890</span>
</li>
{ (transactionCategory === TransactionCategory.AllTransaction) &&
subLi()
}
{ (transactionCategory === TransactionCategory.Escrow) &&
<>
<li className="kv-row">
<span className="k"></span>
<span className="v">NICE PAY</span>
</li>
<li className="kv-row">
<span className="k"></span>
<span className="v">123-45-67890</span>
</li>
</>
}
</motion.ul>
</div>
</>