From 62e8d0224e03c13098d684698cd918c8685c563a Mon Sep 17 00:00:00 2001 From: hamid zarghami Date: Mon, 3 Mar 2025 09:26:25 +0330 Subject: [PATCH] fix financial --- src/pages/receipts/Detail.tsx | 12 +- src/pages/receipts/components/LegalInfo.tsx | 189 ++++++++++---------- src/pages/receipts/components/RealInfo.tsx | 28 +-- 3 files changed, 115 insertions(+), 114 deletions(-) diff --git a/src/pages/receipts/Detail.tsx b/src/pages/receipts/Detail.tsx index 6f2c6a6..f53167f 100644 --- a/src/pages/receipts/Detail.tsx +++ b/src/pages/receipts/Detail.tsx @@ -2,7 +2,6 @@ import { FC } from 'react' import { useTranslation } from 'react-i18next' import { useParams } from 'react-router-dom' import { useGetInvoiceDetail } from './hooks/useReceiptData' -import { useGetFinancialInfo } from '../financial/hooks/useFinancialData' import { ReceiptDetailItemType } from './types/ReceiptTypes' import { NumberFormat } from '../../config/func' import moment from 'moment-jalaali' @@ -16,12 +15,13 @@ import ApproveInvoice from './components/ApproveInvoice' import PayInvoice from './components/PayInvoice' import Input from '../../components/Input' import { Helmet } from 'react-helmet-async' +import { useGetProfile } from '../profile/hooks/useProfileData' const ReceiptsDetail: FC = () => { const { id } = useParams() const { t } = useTranslation('global') - const getProfile = useGetFinancialInfo() + const getProfile = useGetProfile() const getInvoce = useGetInvoiceDetail(id ? id : '') return ( @@ -72,11 +72,11 @@ const ReceiptsDetail: FC = () => { { - getProfile.data?.data?.user?.legalUser ? - + getProfile.data?.data?.user?.financialType === 'LEGAL' ? + : - getProfile.data?.data?.user?.realUser ? - + getProfile.data?.data?.user?.financialType === 'REAL' ? + : } diff --git a/src/pages/receipts/components/LegalInfo.tsx b/src/pages/receipts/components/LegalInfo.tsx index 6c3a3f4..c1b9045 100644 --- a/src/pages/receipts/components/LegalInfo.tsx +++ b/src/pages/receipts/components/LegalInfo.tsx @@ -1,117 +1,118 @@ import { FC, Fragment } from 'react' import { useTranslation } from 'react-i18next' -import { FinancialDataType } from '../../financial/types/FinancialTypes' +import { useGetLegalInfo } from '../../financial/hooks/useFinancialData' +import { useGetProfile } from '../../profile/hooks/useProfileData' -type Props = { - data: FinancialDataType -} -const LegalInfo: FC = ({ data }) => { +const LegalInfo: FC = () => { const { t } = useTranslation('global') + const { data: d, isSuccess } = useGetLegalInfo() + const getProfile = useGetProfile() - return ( - -
-
-
- {t('receip.type_person')} + const data = d?.data?.legalUser + + if (isSuccess) + return ( + +
+
+
+ {t('receip.type_person')} +
+
+ { + t('receip.company') + } +
-
- { - data?.user?.legalUser ? - t('receip.company') : - t('receip.real_person') - } + +
+
+ {t('receip.representativeـname')} +
+
+ {getProfile.data?.data?.user?.firstName + ' ' + getProfile.data?.data?.user?.lastName} +
+
+ +
+
+ {t('receip.company_name')} +
+
+ {data.registrationName} +
+
+
+
+ {t('receip.registration_number')} +
+
+ {data.registrationCode} +
-
-
- {t('receip.representativeـname')} +
+
+
+ {t('receip.tel_company')} +
+
+ {data.phone} +
-
- {data.user?.firstName + ' ' + data.user?.lastName} + +
+
+ {t('receip.national_code')} +
+
+ {data?.nationalIdentity} +
+ +
+
+ {t('receip.postal_code')} +
+
+ {data?.address?.postalCode} +
+
+
-
-
- {t('receip.company_name')} +
+
+
+ {t('receip.state')} +
+
+ {data?.address?.city?.province?.name} +
-
- {data.user?.legalUser?.companyRegisteredName} +
+
+ {t('receip.city')} +
+
+ {data?.address?.city?.name} +
-
-
-
- {t('receip.registration_number')} -
-
- {data.user?.legalUser?.registrationId} -
-
-
-
-
-
- {t('receip.tel_company')} -
-
- {data.user?.legalUser?.number} +
+
+ {t('receip.address')} +
+
+ {data?.address?.fullAddress} +
- -
-
- {t('receip.national_code')} -
-
- {data?.user?.legalUser?.nationalId} -
-
- -
-
- {t('receip.postal_code')} -
-
- {data.user?.address?.postalCode} -
-
- -
- -
-
-
- {t('receip.state')} -
-
- {data.user?.address?.city?.province?.name} -
-
-
-
- {t('receip.city')} -
-
- {data.user?.address?.city?.name} -
-
- -
-
- {t('receip.address')} -
-
- {data.user?.address?.address} -
-
-
- - ) + + ) } export default LegalInfo \ No newline at end of file diff --git a/src/pages/receipts/components/RealInfo.tsx b/src/pages/receipts/components/RealInfo.tsx index 340288a..9ae6149 100644 --- a/src/pages/receipts/components/RealInfo.tsx +++ b/src/pages/receipts/components/RealInfo.tsx @@ -1,15 +1,15 @@ import { FC, Fragment } from 'react' -import { FinancialDataType } from '../../financial/types/FinancialTypes' import { useTranslation } from 'react-i18next' - -type Props = { - data: FinancialDataType -} +import { useGetRealInfo } from '../../financial/hooks/useFinancialData' -const RealInfo: FC = ({ data }) => { + +const RealInfo: FC = () => { const { t } = useTranslation('global') + const { data: d } = useGetRealInfo() + + const data = d?.data?.realUser return ( @@ -28,7 +28,7 @@ const RealInfo: FC = ({ data }) => { {t('receip.fullName')}
- {data.user?.firstName + ' ' + data.user?.lastName} + {data?.firstName + ' ' + data?.lastName}
@@ -37,7 +37,7 @@ const RealInfo: FC = ({ data }) => { {t('financial.father_name')}
- {data.user?.realUser?.fatherName} + {data?.fatherName}
@@ -45,7 +45,7 @@ const RealInfo: FC = ({ data }) => { {t('financial.sex')}
- {data.user?.realUser?.gender === 'male' ? 'مرد' : 'زن'} + {data?.gender === 'MALE' ? 'مرد' : 'زن'}
@@ -56,7 +56,7 @@ const RealInfo: FC = ({ data }) => { {t('financial.phone')}
- {data.user?.phone} + {data?.phone}
@@ -67,7 +67,7 @@ const RealInfo: FC = ({ data }) => { {t('receip.postal_code')}
- {data.user?.address?.postalCode} + {data?.address?.postalCode}
@@ -79,7 +79,7 @@ const RealInfo: FC = ({ data }) => { {t('receip.state')}
- {data.user?.address?.city?.province?.name} + {data?.address?.city?.province?.name}
@@ -87,7 +87,7 @@ const RealInfo: FC = ({ data }) => { {t('receip.city')}
- {data.user?.address?.city?.name} + {data?.address?.city?.name}
@@ -96,7 +96,7 @@ const RealInfo: FC = ({ data }) => { {t('receip.address')}
- {data.user?.address?.address} + {data?.address?.fullAddress}