diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 5196be8..2b38d64 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -248,6 +248,7 @@ "zimbabwe": "Zimbabwe" }, "messages": { + "pageNotFound": "Page not found", "noResualtFound": "No result found.", "serverError": "Internal server error" } diff --git a/public/locales/fa/common.json b/public/locales/fa/common.json index 878b22d..bf8918b 100644 --- a/public/locales/fa/common.json +++ b/public/locales/fa/common.json @@ -185,6 +185,7 @@ "zimbabwe": "زیمبابوه" }, "messages": { + "pageNotFound": "صفحه مورد نظر پیدا نشد.", "noResualtFound": "نتیجه ای یافت نشد.", "serverError": "خطای سمت سرور" }, diff --git a/src/components/NavigateWithToast.tsx b/src/components/NavigateWithToast.tsx new file mode 100644 index 0000000..51a133f --- /dev/null +++ b/src/components/NavigateWithToast.tsx @@ -0,0 +1,24 @@ +import { useToast, type ToastOptions } from '@rkheftan/harmony-ui'; +import React, { useEffect } from 'react'; +import { useTranslation } from 'react-i18next'; +import { Navigate } from 'react-router-dom'; + +export interface NavigateWithToastProps extends ToastOptions { + to: string; + replace?: boolean; + translator?: string; +} + +export const NavigateWithToast = (props: NavigateWithToastProps) => { + const { t } = useTranslation(props.translator ?? 'common'); + const toast = useToast(); + + useEffect(() => { + toast({ + ...props, + message: t(props.message), + }); + }, []); + + return ; +}; diff --git a/src/routes/config.tsx b/src/routes/config.tsx index 760815d..e1e0e01 100644 --- a/src/routes/config.tsx +++ b/src/routes/config.tsx @@ -1,4 +1,5 @@ import { Layout } from '@/components'; +import { NavigateWithToast } from '@/components/NavigateWithToast'; import { AccountCreatedPage } from '@/features/authorization/routes/AccountCreatedPage'; import { Calendar, @@ -65,6 +66,17 @@ export interface RouteConfig { // can lazy load component if needed (ex. lazy(() => import('@/features/home/routes/HomePage'));) export const appRoutes: RouteConfig[] = [ + { + path: '*', + element: ( + + ), + }, { path: '/', element: ,