From 32433c9a2c58cf459d36de40d38f72f09e354a7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D9=85=D9=87=D8=B1=D8=B2=D8=A7=D8=AF=20=D9=82=D8=AF=D8=B1?= =?UTF-8?q?=D8=AA=DB=8C?= Date: Wed, 20 Aug 2025 14:33:15 +0330 Subject: [PATCH 1/2] feat: 404 page redirect with toast added --- public/locales/en/common.json | 1 + public/locales/fa/common.json | 1 + src/components/NavigateWithToast.tsx | 24 ++++++++++++++++++++++++ src/main.tsx | 10 +++++----- src/routes/config.tsx | 12 ++++++++++++ 5 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 src/components/NavigateWithToast.tsx 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/main.tsx b/src/main.tsx index be3d73c..2f74b23 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -5,9 +5,9 @@ import App from './App'; import { AppProviders } from './providers/AppProvider'; createRoot(document.getElementById('root')!).render( - - - - - , + // + + + , + // , ); 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: , From 8a4509ffd7b012b62dc1dc756b443d167433a45e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D9=85=D9=87=D8=B1=D8=B2=D8=A7=D8=AF=20=D9=82=D8=AF=D8=B1?= =?UTF-8?q?=D8=AA=DB=8C?= Date: Wed, 20 Aug 2025 14:49:24 +0330 Subject: [PATCH 2/2] fix: strict mode uncommented --- src/main.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main.tsx b/src/main.tsx index 2f74b23..be3d73c 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -5,9 +5,9 @@ import App from './App'; import { AppProviders } from './providers/AppProvider'; createRoot(document.getElementById('root')!).render( - // - - - , - // , + + + + + , );