mid 셋팅및 코드 정리
This commit is contained in:
119
src/entities/transaction/ui/section/settlement-info-section.tsx
Normal file
119
src/entities/transaction/ui/section/settlement-info-section.tsx
Normal file
@@ -0,0 +1,119 @@
|
||||
import moment from 'moment';
|
||||
import { NumericFormat } from 'react-number-format';
|
||||
import { SectionTitleArrow } from '@/entities/common/ui/section-title-arrow';
|
||||
import { InfoSectionKeys, InfoSectionProps } from '../../model/types';
|
||||
import { SlideDown } from 'react-slidedown';
|
||||
import 'react-slidedown/lib/slidedown.css';
|
||||
|
||||
export const SettlementInfoSection = ({
|
||||
transactionCategory,
|
||||
settlementInfo,
|
||||
serviceCode,
|
||||
isOpen,
|
||||
onClickToOpenInfo
|
||||
}: InfoSectionProps) => {
|
||||
|
||||
const subItems: Record<string, Record<string, string>> = {
|
||||
approvalSettleDate: {name: '승인정산일', type: 'date'},
|
||||
approvalSettleAmount: {name: '승인정산금액', type: 'number'},
|
||||
cancelSettleDate: {name: '취소정산일', type: 'date'},
|
||||
cancelSettleAmount: {name: '취소정산금액', type: 'number'},
|
||||
};
|
||||
|
||||
const openSubItems: Record<string, Array<string>> = {
|
||||
// 신용카드
|
||||
'01': ['approvalSettleDate', 'approvalSettleAmount',
|
||||
'cancelSettleDate', 'cancelSettleAmount'],
|
||||
// 계좌이체
|
||||
'02': ['approvalSettleDate', 'approvalSettleAmount',
|
||||
'cancelSettleDate', 'cancelSettleAmount'],
|
||||
// 가상계좌
|
||||
'03': ['approvalSettleDate', 'approvalSettleAmount',
|
||||
'cancelSettleDate', 'cancelSettleAmount'],
|
||||
// 휴대폰
|
||||
'04': ['approvalSettleDate', 'approvalSettleAmount',
|
||||
'cancelSettleDate', 'cancelSettleAmount'],
|
||||
// 계좌간편결제
|
||||
'26': ['approvalSettleDate', 'approvalSettleAmount',
|
||||
'cancelSettleDate', 'cancelSettleAmount'],
|
||||
// SSG머니
|
||||
'21': ['approvalSettleDate', 'approvalSettleAmount',
|
||||
'cancelSettleDate', 'cancelSettleAmount'],
|
||||
// SSG은행계좌
|
||||
'24': ['approvalSettleDate', 'approvalSettleAmount',
|
||||
'cancelSettleDate', 'cancelSettleAmount'],
|
||||
// 문화상품권
|
||||
'14': ['approvalSettleDate', 'approvalSettleAmount',
|
||||
'cancelSettleDate', 'cancelSettleAmount'],
|
||||
// 티머니페이
|
||||
'31': ['approvalSettleDate', 'approvalSettleAmount',
|
||||
'cancelSettleDate', 'cancelSettleAmount'],
|
||||
};
|
||||
|
||||
const checkValue = (val: any) => {
|
||||
return (!!val || val === 0);
|
||||
};
|
||||
let newSettlementInfo: Record<string, any> | undefined = settlementInfo;
|
||||
const subLi = () => {
|
||||
let rs = [];
|
||||
|
||||
if(!!newSettlementInfo && !!serviceCode && !!openSubItems[serviceCode]){
|
||||
for(let i=0;i<openSubItems[serviceCode].length;i++){
|
||||
let k = openSubItems[serviceCode][i];
|
||||
if(!!k){
|
||||
rs.push(
|
||||
<li
|
||||
key={`key-important-item-${i}`}
|
||||
className="kv-row"
|
||||
>
|
||||
<span className="k">· { subItems[k]?.name }</span>
|
||||
<span className="v">
|
||||
{ (checkValue(newSettlementInfo[k]) && subItems[k]?.type === 'string') &&
|
||||
newSettlementInfo[k]
|
||||
}
|
||||
{ (checkValue(newSettlementInfo[k]) && subItems[k]?.type === 'number') &&
|
||||
<NumericFormat
|
||||
value={ newSettlementInfo[k] }
|
||||
thousandSeparator
|
||||
displayType="text"
|
||||
suffix='원'
|
||||
></NumericFormat>
|
||||
}
|
||||
{ (checkValue(newSettlementInfo[k]) && subItems[k]?.type === 'date') &&
|
||||
moment(newSettlementInfo[k]).format('YYYY.MM.DD')
|
||||
}
|
||||
</span>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
return rs;
|
||||
};
|
||||
|
||||
const onClickToSetOpenInfo = () => {
|
||||
if(!!onClickToOpenInfo){
|
||||
onClickToOpenInfo(InfoSectionKeys.Settlement);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="txn-section">
|
||||
<div
|
||||
className="section-title with-toggle"
|
||||
onClick={ () => onClickToSetOpenInfo() }
|
||||
>
|
||||
정산 정보 <SectionTitleArrow isOpen={ isOpen }></SectionTitleArrow>
|
||||
</div>
|
||||
<SlideDown className={'my-dropdown-slidedown'}>
|
||||
{ !!isOpen &&
|
||||
<ul className="kv-list">
|
||||
{ subLi() }
|
||||
</ul>
|
||||
}
|
||||
</SlideDown>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
};
|
||||
Reference in New Issue
Block a user