type DeliveryStatus = 'ITEM_READY'
| 'DELIVERY_READY'
| 'DELIVERY_ING'
| 'DELIVERY_SUCCESS'
| 'DELIVERY_RETURN'
type ItemStatus = 'ITEM_DELIVERY'
| 'ITEM_DELIVERY_SUCCESS'
| 'ITEM_REFUND'
| 'ITEM_EXCHANGE'
| 'ITEM_RETURN'
const statusCodeTranslator = ({
itemStatus,
deliveryStatus
} : { itemStatus: ItemStatus, deliveryStatus: DeliveryStatus }) => {
const itemStatusCode = {
DELIVERY: 'ITEM_DELIVERY',
DELIVERY_SUCCESS: 'ITEM_DELIVERY_SUCCESS',
REFUND: 'ITEM_REFUND',
EXCHANGE: 'ITEM_EXCHANGE',
RETURN: 'ITEM_RETURN'
};
const itemStatusText: Record<ItemStatus, string> = {
ITEM_DELIVERY: '배송 진행중',
ITEM_DELIVERY_SUCCESS: '배송완료',
ITEM_REFUND: '환불',
ITEM_EXCHANGE: '교환',
ITEM_RETURN: '반품'
};
const deliveryStatusText: Record<DeliveryStatus, string> = {
ITEM_READY: '상품 준비중',
DELIVERY_READY: '배송 준비중',
DELIVERY_ING: '배송중',
DELIVERY_SUCCESS: '배송완료',
DELIVERY_RETURN: '반송(배송실패)',
};
if (itemStatus === itemStatusCode.DELIVERY || itemStatus === itemStatusCode.DELIVERY_SUCCESS) {
return deliveryStatusText[deliveryStatus];
} else return itemStatusText[itemStatus];
};