diff --git a/src/pages/auth/Register.tsx b/src/pages/auth/Register.tsx
index 27f50d4..688ee0a 100644
--- a/src/pages/auth/Register.tsx
+++ b/src/pages/auth/Register.tsx
@@ -3,10 +3,10 @@ import LogoImage from '../../assets/images/logo.svg'
import LogoSmallImage from '../../assets/images/logo-small.svg'
import { useTranslation } from 'react-i18next'
import { Link } from 'react-router-dom'
-import { Pages } from '../../config/Pages'
import RegisterStep1 from './components/RegisterStep1'
import { useAuthStore } from './store/AuthStore'
import RegisterStep2 from './components/RegisterStep2'
+import { buildPath } from '../../helpers/utils'
const Register: FC = () => {
@@ -48,7 +48,7 @@ const Register: FC = () => {
{t('auth.before_registered')}
-
+
{t('auth.login')}
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 826d1e1..c36fdf6 100644
--- a/src/pages/auth/components/RegisterStep2.tsx
+++ b/src/pages/auth/components/RegisterStep2.tsx
@@ -9,7 +9,7 @@ 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 { toast } from '../../../components/Toast'
import { Pages } from '../../../config/Pages'
import { setToken } from '../../../config/func'
import { setRefreshToken } from '../../../config/func'
@@ -56,7 +56,7 @@ const RegisterStep2: FC = () => {
window.location.href = `/${slug}/${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/profile/components/Username.tsx b/src/pages/profile/components/Username.tsx
index 23d8f5f..91e9137 100644
--- a/src/pages/profile/components/Username.tsx
+++ b/src/pages/profile/components/Username.tsx
@@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next'
import Button from '../../../components/Button'
import { useCheckUserName, useUpdateProfile } from '../hooks/useProfileData'
import { CheckUserNameType, UpdateProfileType } from '../types/ProfileTypes'
-import { toast } from 'react-toastify'
+import { toast } from '../../../components/Toast'
import { ErrorType } from '../../../helpers/types'
type Props = {
@@ -54,13 +54,13 @@ const Username: FC = (props: Props) => {
updateProfile.mutate(params, {
onSuccess: () => {
- toast.success(t('profile.username_save_success'))
+ toast('نام کاربری با موفقیت تغییر کرد', 'success')
setCanEdit(false)
setCanSave(false)
setStatus('')
},
onError(error: ErrorType) {
- toast.error(error.response?.data?.error?.message?.[0])
+ toast(error?.response?.data?.message || 'خطا در تغییر نام کاربری', 'error')
},
})
}
diff --git a/src/pages/receipts/Detail.tsx b/src/pages/receipts/Detail.tsx
index 8bfb983..63a6475 100644
--- a/src/pages/receipts/Detail.tsx
+++ b/src/pages/receipts/Detail.tsx
@@ -10,7 +10,7 @@ import Button from '../../components/Button'
import ApproveInvoice from './components/ApproveInvoice'
import PayInvoice from './components/PayInvoice'
import Input from '../../components/Input'
-import { toast } from 'react-toastify'
+import { toast } from '../../components/Toast'
import { ErrorType } from '../../helpers/types'
// import PDFGenerator from '../../components/PDFGenerator'
import { useGetGetWays } from './hooks/useReceiptData'
@@ -34,11 +34,11 @@ const ReceiptsDetail: FC = () => {
}
applyDiscount.mutate(params, {
onSuccess: () => {
- toast.success(t('receip.discount_applied'))
+ toast('فاکتور با موفقیت پرداخت شد', 'success')
getInvoce.refetch()
},
onError: (error: ErrorType) => {
- toast.error(error?.response?.data?.error?.message[0])
+ toast(error?.response?.data?.message || 'خطا در پرداخت فاکتور', 'error')
}
})
}
@@ -46,11 +46,11 @@ const ReceiptsDetail: FC = () => {
const handleRemoveDiscount = () => {
removeDiscount.mutate({ id: id ? id : '' }, {
onSuccess: () => {
- toast.success(t('receip.discount_removed'))
+ toast('فاکتور با موفقیت پرداخت شد', 'success')
getInvoce.refetch()
},
onError: (error: ErrorType) => {
- toast.error(error?.response?.data?.error?.message[0])
+ toast(error?.response?.data?.message || 'خطا در پرداخت فاکتور', 'error')
}
})
}
diff --git a/src/pages/receipts/components/ApproveInvoice.tsx b/src/pages/receipts/components/ApproveInvoice.tsx
index e690de0..7489c2e 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('فاکتور با موفقیت تایید شد', 'success')
refetch()
setShowModal(false)
},
onError: (error: ErrorType) => {
- toast.error(error.response?.data?.error.message[0])
+ toast(error?.response?.data?.message || 'خطا در تایید فاکتور', '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?.message || 'خطا در تایید فاکتور', 'error')
}
})
}
diff --git a/src/pages/request/Request.tsx b/src/pages/request/Request.tsx
index 55b923d..f1038c0 100644
--- a/src/pages/request/Request.tsx
+++ b/src/pages/request/Request.tsx
@@ -7,7 +7,7 @@ import { useTranslation } from 'react-i18next'
import { useFormik } from 'formik'
import * as Yup from 'yup'
import { useState } from 'react'
-import { toast } from 'react-toastify'
+import { toast } from '../../components/Toast'
import { ErrorType } from '../../helpers/types'
import { Pages } from '../../config/Pages'
import { useNavigate, useParams } from 'react-router-dom'
@@ -69,7 +69,7 @@ const Request: FC = () => {
}),
onSubmit: async (values) => {
if (!profileImage || !coverImage) {
- toast.error('لطفا تصاویر را انتخاب کنید')
+ toast('لطفا تصاویر را انتخاب کنید', 'error')
return
}
@@ -112,15 +112,13 @@ const Request: FC = () => {
createCompany.mutate(values, {
onSuccess: () => {
- toast.success('درخواست با موفقیت ثبت شد')
+ toast('درخواست با موفقیت ثبت شد', 'success')
navigate(buildPath(Pages.dashboard, slug))
},
onError: (error: ErrorType) => {
- toast.error(error.response?.data?.error.message[0])
+ toast(error?.response?.data?.message || 'خطا در ارسال درخواست', 'error')
}
})
- toast.success('درخواست با موفقیت ثبت شد')
- // navigate(Pages.request.list)
}
})
diff --git a/src/router/Auth.tsx b/src/router/Auth.tsx
index 22defee..3c8257f 100644
--- a/src/router/Auth.tsx
+++ b/src/router/Auth.tsx
@@ -1,10 +1,38 @@
-import { FC } from 'react'
-import { Route, Routes } from 'react-router-dom'
+import { FC, useEffect } from 'react'
+import { Route, Routes, useParams } from 'react-router-dom'
import { Pages } from '../config/Pages'
import Login from '../pages/auth/Login'
import Register from '../pages/auth/Register'
+import { useGetSlugId } from '../pages/home/hooks/useHomeData'
+import { ErrorType } from '../helpers/types'
+import { toast } from '../components/Toast'
const AuthRouter: FC = () => {
+
+ const { slug } = useParams()
+ const getSlugId = useGetSlugId()
+ useEffect(() => {
+ if (slug) {
+ const slug_id = localStorage.getItem(import.meta.env.VITE_SLUG_ID)
+ const slug_parse = slug_id ? JSON.parse(slug_id) : null
+ if (slug_parse && slug_parse.slug === slug) {
+
+ return
+ } else {
+ getSlugId.mutate(slug, {
+ onSuccess: (data) => {
+ localStorage.setItem(import.meta.env.VITE_SLUG_ID, JSON.stringify(data?.data?.business))
+ window.location.reload()
+ },
+ onError: (error: ErrorType) => {
+ toast(error?.response?.data?.error?.message[0] || 'خطا در دریافت اطلاعات', 'error')
+ // window.location.href = 'https://danakcorp.com'
+ }
+ })
+ }
+ }
+ }, [slug])
+
return (
} />
diff --git a/src/router/Main.tsx b/src/router/Main.tsx
index a474fb2..2fc648c 100644
--- a/src/router/Main.tsx
+++ b/src/router/Main.tsx
@@ -18,7 +18,7 @@ import CompanyDetail from "../pages/company/Detail"
import { useEffect } from "react"
import { useGetSlugId } from "../pages/home/hooks/useHomeData"
import { ErrorType } from "../helpers/types"
-import { toast } from "react-toastify"
+import { toast } from "../components/Toast"
import Request from "../pages/request/Request"
import TicketList from "../pages/ticket/TicketList"
import TicketCreate from "../pages/ticket/CreateTicket"
@@ -43,7 +43,7 @@ const MainRouter = () => {
window.location.reload()
},
onError: (error: ErrorType) => {
- toast.error(error.response?.data?.error.message[0])
+ toast(error?.response?.data?.error?.message[0] || 'خطا در دریافت اطلاعات', 'error')
// window.location.href = 'https://danakcorp.com'
}
})