diff --git a/src/entities/transaction/ui/detail/cash-receit-detail.tsx b/src/entities/transaction/ui/detail/cash-receit-detail.tsx index a9adace..c7061d9 100644 --- a/src/entities/transaction/ui/detail/cash-receit-detail.tsx +++ b/src/entities/transaction/ui/detail/cash-receit-detail.tsx @@ -25,6 +25,7 @@ import { snackBar } from '@/shared/lib'; import { DetailMotionDuration, DetailMotionStyle, DetailMotionVariants } from '@/entities/common/model/constant'; import { FullMenuClose } from '@/entities/common/ui/full-menu-close'; import { checkGrant } from '@/shared/lib/check-grant'; +import { showAlert } from '@/widgets/show-alert'; export interface CashReceiptDetailProps { detailOn: boolean; diff --git a/src/pages/settlement/list/detail-page.tsx b/src/pages/settlement/list/detail-page.tsx deleted file mode 100644 index ad8b1af..0000000 --- a/src/pages/settlement/list/detail-page.tsx +++ /dev/null @@ -1,175 +0,0 @@ -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 { AmountInfoWrap } from '@/entities/settlement/ui/info-wrap/amount-info-wrap'; -import { SettlementInfoWrap } from '@/entities/settlement/ui/info-wrap/settlement-info-wrap'; -import { TransactionInfoWrap } from '@/entities/settlement/ui/info-wrap/transaction-info-wrap' -import { HeaderType } from '@/entities/common/model/types'; -import { - AmountInfo, - InfoWrapKeys, - SettlementInfo, - SettlementPeriodType, - SettlementsHistoryDetailParams, - SettlementsHistoryDetailResponse, - SettlementsTransactionDetailParams, - SettlementsTransactionDetailResponse, - TransactionInfo -} from '@/entities/settlement/model/types'; -import { - useSetOnBack, - useSetHeaderTitle, - useSetHeaderType, - useSetFooterMode -} from '@/widgets/sub-layout/use-sub-layout'; -import { useSettlementsHistoryDetailMutation } from '@/entities/settlement/api/use-settlements-history-detail-mutation'; -import { useSettlementsTransactionDetailMutation } from '@/entities/settlement/api/use-settlements-transaction-detail-mutation'; -import { NumericFormat } from 'react-number-format'; -import moment from 'moment'; -import { useTranslation } from 'react-i18next'; - -export const DetailPage = () => { - const { navigate } = useNavigate(); - const { t, i18n } = useTranslation(); - const location = useLocation(); - - const [amountInfo, setAmountInfo] = useState(); - const [settlementInfo, setSettlementInfo] = useState(); - const [settlementAmount, setSettlementAmount] = useState(); - const [settlementDate, setSettlementDate] = useState(); - const [transactionInfo, setTransactionInfo] = useState(); - const [transactionAmount, setTransactionAmount] = useState(); - const [merchantName, setMerchantName] = useState(); - - const [showSettlement, setShowSettlement] = useState(false); - const [showTransaction, setShowTransaction] = useState(false); - - const { mutateAsync: settlementsHistoryDetail } = useSettlementsHistoryDetailMutation(); - const { mutateAsync: settlementsTransactionDetail } = useSettlementsTransactionDetailMutation(); - - const settlementId = location.state.settlementId; - const approvalNumber = location.state.approvalNumber; - const periodType = location.state.periodType; - const tid = location.state.tid; - - - useSetHeaderTitle(t('settlement.detailTitle')); - useSetHeaderType(HeaderType.RightClose); - useSetOnBack(() => { - navigate(PATHS.settlement.list); - }); - useSetFooterMode(false); - - const callSettlementDetail = () => { - let params: SettlementsHistoryDetailParams = { - settlementId: settlementId - }; - - settlementsHistoryDetail(params).then((rs: SettlementsHistoryDetailResponse) => { - setAmountInfo(rs.amountInfo); - setSettlementInfo(rs.settlementInfo); - setSettlementAmount(rs.settlementAmount); - setSettlementDate(rs.settlementDate); - }); - }; - const callTransactionDetail = () => { - let params: SettlementsTransactionDetailParams = { - tid: tid - }; - - settlementsTransactionDetail(params).then((rs: SettlementsTransactionDetailResponse) => { - setAmountInfo(rs.amountInfo); - setTransactionInfo(rs.transactionInfo); - setTransactionAmount(rs.transactionAmount); - setMerchantName(rs.merchantName); - }); - }; - - const onClickToShowInfo = (infoWrapKey: InfoWrapKeys) => { - if(infoWrapKey === InfoWrapKeys.Settlement){ - setShowSettlement(!showSettlement); - } - else if(infoWrapKey === InfoWrapKeys.Transaction){ - setShowTransaction(!showTransaction); - } - }; - - useEffect(() => { - if(periodType === SettlementPeriodType.SETTLEMENT_DATE){ - callSettlementDetail(); - } - else if(periodType === SettlementPeriodType.TRANSACTION_DATE){ - callTransactionDetail(); - } - }, []); - - return ( - <> -
-
-
-
-
- { (periodType === SettlementPeriodType.SETTLEMENT_DATE) && -
-
-
- {i18n.language === 'en' && {t('home.currencySymbol')}} - - {i18n.language !== 'en' && {t('home.currencyWon')}} -
-
-
{ moment(settlementDate).format('YYYY.MM.DD') }
-
- } - { (periodType === SettlementPeriodType.TRANSACTION_DATE) && -
-
-
- {i18n.language === 'en' && {t('home.currencySymbol')}} - - {i18n.language !== 'en' && {t('home.currencyWon')}} -
-
-
{ merchantName }
-
- } -
- - -
- { (periodType === SettlementPeriodType.SETTLEMENT_DATE) && - onClickToShowInfo(infoWrapKey) } - > - } - { (periodType === SettlementPeriodType.TRANSACTION_DATE) && - onClickToShowInfo(infoWrapKey) } - > - } -
-
-
-
-
- - ); -}; \ No newline at end of file