import { useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { useLocation } from 'react-router'; import { PATHS } from '@/shared/constants/paths'; import { useNavigate } from '@/shared/lib/hooks/use-navigate'; import { useBillingDetailMutation } from '@/entities/transaction/api/use-billing-detail-mutation'; import { BillingInfoSection } from '@/entities/transaction/ui/section/billing-info-section'; import { HeaderType } from '@/entities/common/model/types'; import { TransactionCategory, BillingDetailParams, BillingDetailResponse, BillingInfo, AmountInfo } from '@/entities/transaction/model/types'; import { useSetOnBack, useSetHeaderTitle, useSetHeaderType, useSetFooterMode } from '@/widgets/sub-layout/use-sub-layout'; import { NumericFormat } from 'react-number-format'; import { C } from 'node_modules/react-router/dist/development/index-react-server-client-DRhjXpk2.mjs'; import { AmountInfoSection } from '@/entities/transaction/ui/section/amount-info-section'; export const BillingDetailPage = () => { const { navigate } = useNavigate(); const { t, i18n } = useTranslation(); const location = useLocation(); const tid = location?.state.tid; const serviceCode = location?.state.serviceCode; const [billingInfo, setBillingInfo] = useState(); const [amountInfo, setAmountInfo] = useState(); useSetHeaderTitle(t('billing.detailTitle')); useSetHeaderType(HeaderType.RightClose); useSetOnBack(() => { navigate(PATHS.transaction.billing.list); }); useSetFooterMode(false); const { mutateAsync: billingDetail } = useBillingDetailMutation(); const callDetail = () => { let billingDetailParams: BillingDetailParams = { tid: tid }; billingDetail(billingDetailParams).then((rs: BillingDetailResponse) => { setBillingInfo(rs); setAmountInfo({ transactionAmount: rs.transactionAmount, buyerName: rs.buyerName }) }); }; useEffect(() => { callDetail(); }, []); return ( <>
{ i18n.language === 'en' && { t('home.currencySymbol') } } { i18n.language !== 'en' && { t('home.currencyWon') } }
{ amountInfo?.buyerName }
); };