(
- `/admin/catalogue/${id}`,
+ `/public/catalogue/${id}`,
);
return data;
};
diff --git a/src/router/MainRouter.tsx b/src/router/MainRouter.tsx
index 118fca6..14e8d4b 100644
--- a/src/router/MainRouter.tsx
+++ b/src/router/MainRouter.tsx
@@ -2,6 +2,7 @@ import SideBar from '@/shared/SideBar'
import Header from '@/shared/Header'
import { Route, Routes, useLocation } from 'react-router-dom'
import { Paths } from '@/config/Paths'
+import PrivateRoute from '@/router/PrivateRoute'
import { clx } from '@/helpers/utils'
import { useSharedStore } from '@/shared/store/sharedStore'
import Home from '@/pages/home/Home'
@@ -46,11 +47,46 @@ const MainRouter = () => {
)}>
- } />
- } />
- } />
- } />
- } />
+
+
+
+ }
+ />
+
+
+
+ }
+ />
+
+
+
+ }
+ />
+
+
+
+ }
+ />
+
+
+
+ }
+ />
diff --git a/src/router/PrivateRoute.tsx b/src/router/PrivateRoute.tsx
new file mode 100644
index 0000000..f1b9a56
--- /dev/null
+++ b/src/router/PrivateRoute.tsx
@@ -0,0 +1,41 @@
+import { useAuth } from '@/context/AuthContext'
+import { Paths } from '@/config/Paths'
+import { type FC, type ReactNode } from 'react'
+import { Navigate, useLocation } from 'react-router-dom'
+
+type PrivateRouteProps = {
+ children: ReactNode
+ /** When true (default), user must be logged in to access the route */
+ requireAuth?: boolean
+ /** Redirect target when auth is required but user is not logged in */
+ redirectTo?: string
+}
+
+const PrivateRoute: FC = ({
+ children,
+ requireAuth = true,
+ redirectTo = Paths.home,
+}) => {
+ const { isAuthenticated, isChecking } = useAuth()
+ const location = useLocation()
+
+ if (!requireAuth) {
+ return children
+ }
+
+ if (isChecking) {
+ return (
+
+ )
+ }
+
+ if (!isAuthenticated) {
+ return
+ }
+
+ return children
+}
+
+export default PrivateRoute