feat(admin): implement Phase 3 Admin SPA Router and Dual-Token Auth integration
This commit is contained in:
1 parent
71e19bfe43
commit
eaa2621a17
11 files changed
+561
-153
No files matched your search
@@ -0,0 +1,69 @@
|
||||
import { lazy, ComponentType } from 'react';
|
||||
import { createBrowserRouter, Navigate } from 'react-router-dom';
|
||||
import Layout from '../components/Layout';
|
||||
import ProtectedRoute from '../components/ProtectedRoute';
|
||||
import Login from '../pages/Login';
|
||||
|
||||
// Lazy loading admin pages
|
||||
const Dashboard = lazy(() => import('../pages/Dashboard'));
|
||||
const Users = lazy(() => import('../pages/Users'));
|
||||
const Products = lazy(() => import('../pages/Products'));
|
||||
const Orders = lazy(() => import('../pages/Orders'));
|
||||
const Coupons = lazy(() => import('../pages/Coupons'));
|
||||
const Settings = lazy(() => import('../pages/Settings'));
|
||||
const Reports = lazy(() => import('../pages/Reports'));
|
||||
const Categories = lazy(() => import('../pages/Categories'));
|
||||
const Blogs = lazy(() => import('../pages/Blogs'));
|
||||
const Wiki = lazy(() => import('../pages/Wiki'));
|
||||
const Pets = lazy(() => import('../pages/Pets'));
|
||||
const UITexts = lazy(() => import('../pages/UITexts'));
|
||||
const Media = lazy(() => import('../pages/Media'));
|
||||
const CMS = lazy(() => import('../pages/CMS'));
|
||||
const WholesaleApplications = lazy(() => import('../pages/WholesaleApplications'));
|
||||
const Videos = lazy(() => import('../pages/Videos'));
|
||||
const ContactSubmissions = lazy(() => import('../pages/ContactSubmissions'));
|
||||
|
||||
export interface AdminRouteConfig {
|
||||
path: string;
|
||||
component: ComponentType;
|
||||
index?: boolean;
|
||||
}
|
||||
|
||||
export const router = createBrowserRouter([
|
||||
{
|
||||
path: '/login',
|
||||
element: <Login />,
|
||||
},
|
||||
{
|
||||
element: <ProtectedRoute />,
|
||||
children: [
|
||||
{
|
||||
path: '/',
|
||||
element: <Layout />,
|
||||
children: [
|
||||
{ index: true, element: <Dashboard /> },
|
||||
{ path: 'users/*', element: <Users /> },
|
||||
{ path: 'products/*', element: <Products /> },
|
||||
{ path: 'orders/*', element: <Orders /> },
|
||||
{ path: 'coupons/*', element: <Coupons /> },
|
||||
{ path: 'settings/*', element: <Settings /> },
|
||||
{ path: 'reports/*', element: <Reports /> },
|
||||
{ path: 'categories/*', element: <Categories /> },
|
||||
{ path: 'blogs/*', element: <Blogs /> },
|
||||
{ path: 'wiki/*', element: <Wiki /> },
|
||||
{ path: 'videos/*', element: <Videos /> },
|
||||
{ path: 'pets/*', element: <Pets /> },
|
||||
{ path: 'ui-texts/*', element: <UITexts /> },
|
||||
{ path: 'media/*', element: <Media /> },
|
||||
{ path: 'cms/*', element: <CMS /> },
|
||||
{ path: 'wholesale/*', element: <WholesaleApplications /> },
|
||||
{ path: 'contact/*', element: <ContactSubmissions /> },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: '*',
|
||||
element: <Navigate to="/" replace />,
|
||||
},
|
||||
]);
|
||||
Reference in new issue
Block a user