fix problem show toast

This commit is contained in:
hamid zarghami
2025-05-20 15:36:31 +03:30
parent 7f862c2ca5
commit 35979729d3
6 changed files with 19 additions and 19 deletions
+2 -2
View File
@@ -8,7 +8,7 @@ import { useAuthStore } from '../store/AuthStore'
import Error from '../../../components/Error' import Error from '../../../components/Error'
import Button from '../../../components/Button' import Button from '../../../components/Button'
import { useCheckHasAccountRegister, useLoginWithOtp } from '../hooks/useAuthData' import { useCheckHasAccountRegister, useLoginWithOtp } from '../hooks/useAuthData'
import { toast } from 'react-toastify' import { toast } from '../../../components/Toast'
import { ErrorType } from '../../../helpers/types' import { ErrorType } from '../../../helpers/types'
const RegisterStep1: FC = () => { const RegisterStep1: FC = () => {
@@ -33,7 +33,7 @@ const RegisterStep1: FC = () => {
setStepLogin(2) setStepLogin(2)
}, },
onError(error: ErrorType) { onError(error: ErrorType) {
toast.error(error?.response?.data?.error?.message[0]) toast(error?.response?.data?.error?.message[0], 'error')
}, },
}) })
}, },
+2 -2
View File
@@ -9,11 +9,11 @@ import DatePickerComponent from '../../../components/DatePicker'
import Button from '../../../components/Button' import Button from '../../../components/Button'
import { useRegister } from '../hooks/useAuthData' import { useRegister } from '../hooks/useAuthData'
import { ErrorType } from '../../../helpers/types' import { ErrorType } from '../../../helpers/types'
import { toast } from 'react-toastify'
import { Pages } from '../../../config/Pages' import { Pages } from '../../../config/Pages'
import { setToken } from '../../../config/func' import { setToken } from '../../../config/func'
import { setRefreshToken } from '../../../config/func' import { setRefreshToken } from '../../../config/func'
import { getRedirectUrl } from '../../../config/func' import { getRedirectUrl } from '../../../config/func'
import { toast } from '../../../components/Toast'
const RegisterStep2: FC = () => { const RegisterStep2: FC = () => {
const { t } = useTranslation('global') const { t } = useTranslation('global')
@@ -59,7 +59,7 @@ const RegisterStep2: FC = () => {
window.location.href = Pages.dashboard window.location.href = Pages.dashboard
}, },
onError(error: ErrorType) { onError(error: ErrorType) {
toast.error(error?.response?.data?.error?.message[0]) toast(error?.response?.data?.error?.message[0], 'error')
}, },
}) })
}, },
+3 -3
View File
@@ -10,7 +10,7 @@ import * as Yup from 'yup'
import { useCreateLegalUser, useGetCities, useGetLegalInfo, useGetProvines } from '../hooks/useFinancialData' import { useCreateLegalUser, useGetCities, useGetLegalInfo, useGetProvines } from '../hooks/useFinancialData'
import Select from '../../../components/Select' import Select from '../../../components/Select'
import PageLoading from '../../../components/PageLoading' import PageLoading from '../../../components/PageLoading'
import { toast } from 'react-toastify' import { toast } from '../../../components/Toast'
import { ErrorType } from '../../../helpers/types' import { ErrorType } from '../../../helpers/types'
import { useGetProfile } from '../../profile/hooks/useProfileData' import { useGetProfile } from '../../profile/hooks/useProfileData'
@@ -53,11 +53,11 @@ const Legal: FC = () => {
} }
createLegalUser.mutate(params, { createLegalUser.mutate(params, {
onSuccess: () => { onSuccess: () => {
toast.success(t('success')) toast(t('success'), 'success')
window.location.reload() window.location.reload()
}, },
onError(error: ErrorType) { onError(error: ErrorType) {
toast.error(error.response?.data?.error.message[0]) toast(error.response?.data?.error.message[0], 'error')
}, },
}) })
} }
+3 -3
View File
@@ -9,7 +9,7 @@ import { InfoCircle, TickCircle } from 'iconsax-react'
import { CreateRealUserType, ProvinesItemType } from '../types/FinancialTypes' import { CreateRealUserType, ProvinesItemType } from '../types/FinancialTypes'
import * as Yup from 'yup' import * as Yup from 'yup'
import { useCreateRealUser, useGetCities, useGetProvines, useGetRealInfo } from '../hooks/useFinancialData' import { useCreateRealUser, useGetCities, useGetProvines, useGetRealInfo } from '../hooks/useFinancialData'
import { toast } from 'react-toastify' import { toast } from '../../../components/Toast'
import { ErrorType } from '../../../helpers/types' import { ErrorType } from '../../../helpers/types'
import DatePickerComponent from '../../../components/DatePicker' import DatePickerComponent from '../../../components/DatePicker'
import { useGetProfile } from '../../profile/hooks/useProfileData' import { useGetProfile } from '../../profile/hooks/useProfileData'
@@ -60,11 +60,11 @@ const Personal: FC = () => {
} }
createRealUser.mutate(params, { createRealUser.mutate(params, {
onSuccess: () => { onSuccess: () => {
toast.success(t('success')) toast(t('success'), 'success')
window.location.reload() window.location.reload()
}, },
onError(error: ErrorType) { onError(error: ErrorType) {
toast.error(error.response?.data?.error.message[0]) toast(error.response?.data?.error.message[0], 'error')
}, },
}) })
} }
+5 -5
View File
@@ -16,7 +16,7 @@ import PayInvoice from './components/PayInvoice'
import Input from '../../components/Input' import Input from '../../components/Input'
import { Helmet } from 'react-helmet-async' import { Helmet } from 'react-helmet-async'
import { useGetProfile } from '../profile/hooks/useProfileData' import { useGetProfile } from '../profile/hooks/useProfileData'
import { toast } from 'react-toastify' import { toast } from '../../components/Toast'
import { ErrorType } from '../../helpers/types' import { ErrorType } from '../../helpers/types'
import PDFGenerator from '../../components/PDFGenerator' import PDFGenerator from '../../components/PDFGenerator'
import { useGetGetWays } from '../wallet/hooks/useWalletData' import { useGetGetWays } from '../wallet/hooks/useWalletData'
@@ -41,11 +41,11 @@ const ReceiptsDetail: FC = () => {
} }
applyDiscount.mutate(params, { applyDiscount.mutate(params, {
onSuccess: () => { onSuccess: () => {
toast.success(t('receip.discount_applied')) toast(t('receip.discount_applied'), 'success')
getInvoce.refetch() getInvoce.refetch()
}, },
onError: (error: ErrorType) => { 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 = () => { const handleRemoveDiscount = () => {
removeDiscount.mutate({ id: id ? id : '' }, { removeDiscount.mutate({ id: id ? id : '' }, {
onSuccess: () => { onSuccess: () => {
toast.success(t('receip.discount_removed')) toast(t('receip.discount_removed'), 'success')
getInvoce.refetch() getInvoce.refetch()
}, },
onError: (error: ErrorType) => { onError: (error: ErrorType) => {
toast.error(error?.response?.data?.error?.message[0]) toast(error?.response?.data?.error?.message[0], 'error')
} }
}) })
} }
@@ -4,7 +4,7 @@ import { TickCircle } from 'iconsax-react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { useApproveInvoice, useRequestApprove } from '../hooks/useReceiptData' import { useApproveInvoice, useRequestApprove } from '../hooks/useReceiptData'
import { ErrorType } from '../../../helpers/types' import { ErrorType } from '../../../helpers/types'
import { toast } from 'react-toastify' import { toast } from '../../../components/Toast'
import { clx } from '../../../helpers/utils' import { clx } from '../../../helpers/utils'
import { useGetProfile } from '../../profile/hooks/useProfileData' import { useGetProfile } from '../../profile/hooks/useProfileData'
import { RequestApproveInvoiceType } from '../types/ReceiptTypes' import { RequestApproveInvoiceType } from '../types/ReceiptTypes'
@@ -31,12 +31,12 @@ const ApproveInvoice: FC<Props> = ({ id, refetch, status }) => {
const handleConfrim = () => { const handleConfrim = () => {
approveInvoce.mutate({ code: code, id: id, phone: getProfile.data?.data?.user?.phone }, { approveInvoce.mutate({ code: code, id: id, phone: getProfile.data?.data?.user?.phone }, {
onSuccess: () => { onSuccess: () => {
toast.success(t('success')) toast(t('success'), 'success')
refetch() refetch()
setShowModal(false) setShowModal(false)
}, },
onError: (error: ErrorType) => { 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<Props> = ({ id, refetch, status }) => {
reset() reset()
}, },
onError: (error: ErrorType) => { onError: (error: ErrorType) => {
toast.error(error.response?.data?.error.message[0]) toast(error.response?.data?.error.message[0], 'error')
} }
}) })
} }