From 35979729d3800db08e4a0283188d5b8c01cf7723 Mon Sep 17 00:00:00 2001 From: hamid zarghami Date: Tue, 20 May 2025 15:36:31 +0330 Subject: [PATCH] fix problem show toast --- src/pages/auth/components/RegisterStep1.tsx | 4 ++-- src/pages/auth/components/RegisterStep2.tsx | 4 ++-- src/pages/financial/components/Legal.tsx | 6 +++--- src/pages/financial/components/Personal.tsx | 6 +++--- src/pages/receipts/Detail.tsx | 10 +++++----- src/pages/receipts/components/ApproveInvoice.tsx | 8 ++++---- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/pages/auth/components/RegisterStep1.tsx b/src/pages/auth/components/RegisterStep1.tsx index 9122f13..c07b7ab 100644 --- a/src/pages/auth/components/RegisterStep1.tsx +++ b/src/pages/auth/components/RegisterStep1.tsx @@ -8,7 +8,7 @@ import { useAuthStore } from '../store/AuthStore' import Error from '../../../components/Error' import Button from '../../../components/Button' import { useCheckHasAccountRegister, useLoginWithOtp } from '../hooks/useAuthData' -import { toast } from 'react-toastify' +import { toast } from '../../../components/Toast' import { ErrorType } from '../../../helpers/types' const RegisterStep1: FC = () => { @@ -33,7 +33,7 @@ const RegisterStep1: FC = () => { setStepLogin(2) }, onError(error: ErrorType) { - toast.error(error?.response?.data?.error?.message[0]) + toast(error?.response?.data?.error?.message[0], 'error') }, }) }, diff --git a/src/pages/auth/components/RegisterStep2.tsx b/src/pages/auth/components/RegisterStep2.tsx index e3adfa2..74ba3cb 100644 --- a/src/pages/auth/components/RegisterStep2.tsx +++ b/src/pages/auth/components/RegisterStep2.tsx @@ -9,11 +9,11 @@ import DatePickerComponent from '../../../components/DatePicker' import Button from '../../../components/Button' import { useRegister } from '../hooks/useAuthData' import { ErrorType } from '../../../helpers/types' -import { toast } from 'react-toastify' import { Pages } from '../../../config/Pages' import { setToken } from '../../../config/func' import { setRefreshToken } from '../../../config/func' import { getRedirectUrl } from '../../../config/func' +import { toast } from '../../../components/Toast' const RegisterStep2: FC = () => { const { t } = useTranslation('global') @@ -59,7 +59,7 @@ const RegisterStep2: FC = () => { window.location.href = Pages.dashboard }, onError(error: ErrorType) { - toast.error(error?.response?.data?.error?.message[0]) + toast(error?.response?.data?.error?.message[0], 'error') }, }) }, diff --git a/src/pages/financial/components/Legal.tsx b/src/pages/financial/components/Legal.tsx index a182bd9..7ed500d 100644 --- a/src/pages/financial/components/Legal.tsx +++ b/src/pages/financial/components/Legal.tsx @@ -10,7 +10,7 @@ import * as Yup from 'yup' import { useCreateLegalUser, useGetCities, useGetLegalInfo, useGetProvines } from '../hooks/useFinancialData' import Select from '../../../components/Select' import PageLoading from '../../../components/PageLoading' -import { toast } from 'react-toastify' +import { toast } from '../../../components/Toast' import { ErrorType } from '../../../helpers/types' import { useGetProfile } from '../../profile/hooks/useProfileData' @@ -53,11 +53,11 @@ const Legal: FC = () => { } createLegalUser.mutate(params, { onSuccess: () => { - toast.success(t('success')) + toast(t('success'), 'success') window.location.reload() }, onError(error: ErrorType) { - toast.error(error.response?.data?.error.message[0]) + toast(error.response?.data?.error.message[0], 'error') }, }) } diff --git a/src/pages/financial/components/Personal.tsx b/src/pages/financial/components/Personal.tsx index 3f30b65..240e087 100644 --- a/src/pages/financial/components/Personal.tsx +++ b/src/pages/financial/components/Personal.tsx @@ -9,7 +9,7 @@ import { InfoCircle, TickCircle } from 'iconsax-react' import { CreateRealUserType, ProvinesItemType } from '../types/FinancialTypes' import * as Yup from 'yup' import { useCreateRealUser, useGetCities, useGetProvines, useGetRealInfo } from '../hooks/useFinancialData' -import { toast } from 'react-toastify' +import { toast } from '../../../components/Toast' import { ErrorType } from '../../../helpers/types' import DatePickerComponent from '../../../components/DatePicker' import { useGetProfile } from '../../profile/hooks/useProfileData' @@ -60,11 +60,11 @@ const Personal: FC = () => { } createRealUser.mutate(params, { onSuccess: () => { - toast.success(t('success')) + toast(t('success'), 'success') window.location.reload() }, onError(error: ErrorType) { - toast.error(error.response?.data?.error.message[0]) + toast(error.response?.data?.error.message[0], 'error') }, }) } diff --git a/src/pages/receipts/Detail.tsx b/src/pages/receipts/Detail.tsx index e9b4c6b..0f4120e 100644 --- a/src/pages/receipts/Detail.tsx +++ b/src/pages/receipts/Detail.tsx @@ -16,7 +16,7 @@ import PayInvoice from './components/PayInvoice' import Input from '../../components/Input' import { Helmet } from 'react-helmet-async' import { useGetProfile } from '../profile/hooks/useProfileData' -import { toast } from 'react-toastify' +import { toast } from '../../components/Toast' import { ErrorType } from '../../helpers/types' import PDFGenerator from '../../components/PDFGenerator' import { useGetGetWays } from '../wallet/hooks/useWalletData' @@ -41,11 +41,11 @@ const ReceiptsDetail: FC = () => { } applyDiscount.mutate(params, { onSuccess: () => { - toast.success(t('receip.discount_applied')) + toast(t('receip.discount_applied'), 'success') getInvoce.refetch() }, onError: (error: ErrorType) => { - toast.error(error?.response?.data?.error?.message[0]) + toast(error?.response?.data?.error?.message[0], 'error') } }) } @@ -53,11 +53,11 @@ const ReceiptsDetail: FC = () => { const handleRemoveDiscount = () => { removeDiscount.mutate({ id: id ? id : '' }, { onSuccess: () => { - toast.success(t('receip.discount_removed')) + toast(t('receip.discount_removed'), 'success') getInvoce.refetch() }, onError: (error: ErrorType) => { - toast.error(error?.response?.data?.error?.message[0]) + toast(error?.response?.data?.error?.message[0], 'error') } }) } diff --git a/src/pages/receipts/components/ApproveInvoice.tsx b/src/pages/receipts/components/ApproveInvoice.tsx index e690de0..4c7e8dc 100644 --- a/src/pages/receipts/components/ApproveInvoice.tsx +++ b/src/pages/receipts/components/ApproveInvoice.tsx @@ -4,7 +4,7 @@ import { TickCircle } from 'iconsax-react' import { useTranslation } from 'react-i18next' import { useApproveInvoice, useRequestApprove } from '../hooks/useReceiptData' import { ErrorType } from '../../../helpers/types' -import { toast } from 'react-toastify' +import { toast } from '../../../components/Toast' import { clx } from '../../../helpers/utils' import { useGetProfile } from '../../profile/hooks/useProfileData' import { RequestApproveInvoiceType } from '../types/ReceiptTypes' @@ -31,12 +31,12 @@ const ApproveInvoice: FC = ({ id, refetch, status }) => { const handleConfrim = () => { approveInvoce.mutate({ code: code, id: id, phone: getProfile.data?.data?.user?.phone }, { onSuccess: () => { - toast.success(t('success')) + toast(t('success'), 'success') refetch() setShowModal(false) }, onError: (error: ErrorType) => { - toast.error(error.response?.data?.error.message[0]) + toast(error.response?.data?.error.message[0], 'error') } }) } @@ -52,7 +52,7 @@ const ApproveInvoice: FC = ({ id, refetch, status }) => { reset() }, onError: (error: ErrorType) => { - toast.error(error.response?.data?.error.message[0]) + toast(error.response?.data?.error.message[0], 'error') } }) }