import type { ComponentType } from 'react';
import { createBrowserRouter, Navigate } from 'react-router-dom';
import Layout from '../components/Layout';
import ProtectedRoute from '../components/ProtectedRoute';
import { RouteErrorBoundary } from '../components/RouteErrorBoundary';
import Login from '../pages/Login';
import { lazyWithRetry } from '../utils/lazyWithRetry';
// Lazy loading admin pages with automatic retry and cache recovery
const Dashboard = lazyWithRetry(() => import('../pages/Dashboard'));
const Users = lazyWithRetry(() => import('../pages/Users'));
const Products = lazyWithRetry(() => import('../pages/Products'));
const Orders = lazyWithRetry(() => import('../pages/Orders'));
const Coupons = lazyWithRetry(() => import('../pages/Coupons'));
const Settings = lazyWithRetry(() => import('../pages/Settings'));
const Reports = lazyWithRetry(() => import('../pages/Reports'));
const Categories = lazyWithRetry(() => import('../pages/Categories'));
const Blogs = lazyWithRetry(() => import('../pages/Blogs'));
const Wiki = lazyWithRetry(() => import('../pages/Wiki'));
const Pets = lazyWithRetry(() => import('../pages/Pets'));
const UITexts = lazyWithRetry(() => import('../pages/UITexts'));
const Media = lazyWithRetry(() => import('../pages/Media'));
const CMS = lazyWithRetry(() => import('../pages/CMS'));
const WholesaleApplications = lazyWithRetry(() => import('../pages/WholesaleApplications'));
const Videos = lazyWithRetry(() => import('../pages/Videos'));
const ContactSubmissions = lazyWithRetry(() => import('../pages/ContactSubmissions'));
const BannersManager = lazyWithRetry(() => import('../pages/BannersManager'));
const SmartAdvisorManager = lazyWithRetry(() => import('../pages/SmartAdvisorManager'));
const TestimonialsManager = lazyWithRetry(() => import('../pages/TestimonialsManager'));
const IngredientsManager = lazyWithRetry(() => import('../pages/IngredientsManager'));
const PrescriptionsManager = lazyWithRetry(() => import('../pages/PrescriptionsManager'));
const B2BManager = lazyWithRetry(() => import('../pages/B2BManager'));
const SeoSettingsPage = lazyWithRetry(() => import('../pages/SeoSettingsPage'));
const FinancialSettingsPage = lazyWithRetry(() => import('../pages/FinancialSettingsPage'));
const PaymentGatewaysPage = lazyWithRetry(() => import('../pages/PaymentGatewaysPage'));
const ZibalPortalPage = lazyWithRetry(() => import('../pages/ZibalPortalPage'));
const ShippingSettingsPage = lazyWithRetry(() => import('../pages/ShippingSettingsPage'));
const SystemSettingsPage = lazyWithRetry(() => import('../pages/SystemSettingsPage'));
const SmsSettingsPage = lazyWithRetry(() => import('../pages/SmsSettingsPage'));
const SslSettingsPage = lazyWithRetry(() => import('../pages/SslSettingsPage'));
const ApiKeysPage = lazyWithRetry(() => import('../pages/ApiKeysPage'));
const Transactions = lazyWithRetry(() => import('../pages/Transactions'));
const Tickets = lazyWithRetry(() => import('../pages/Tickets'));
const Reviews = lazyWithRetry(() => import('../pages/Reviews'));
const DoctorsManager = lazyWithRetry(() => import('../pages/DoctorsManager'));
const FAQManager = lazyWithRetry(() => import('../pages/FAQManager'));
const MenuManager = lazyWithRetry(() => import('../pages/MenuManager'));
const MonitoringPage = lazyWithRetry(() => import('../pages/MonitoringPage'));
const ApprovalsPage = lazyWithRetry(() => import('../pages/ApprovalsPage'));
const AuditHistoryPage = lazyWithRetry(() => import('../pages/AuditHistoryPage'));
const TasksManagementPage = lazyWithRetry(() => import('../pages/TasksManagementPage'));
export interface AdminRouteConfig {
path: string;
component: ComponentType;
index?: boolean;
}
export const router = createBrowserRouter([
{
path: '/login',
element: ,
errorElement: ,
},
{
element: ,
errorElement: ,
children: [
{
path: '/',
element: ,
errorElement: ,
children: [
{ index: true, element: },
{ path: 'users/*', element: },
{ path: 'products/*', element: },
{ path: 'orders/*', element: },
{ path: 'transactions/*', element: },
{ path: 'zibal-portal/*', element: },
{ path: 'coupons/*', element: },
{ path: 'settings', element: },
{ path: 'settings/payment-methods', element: },
{ path: 'settings/shipping', element: },
{ path: 'settings/ssl', element: },
{ path: 'settings/api-keys', element: },
{ path: 'settings/sms', element: },
{ path: 'settings/seo', element: },
{ path: 'settings/financial', element: },
{ path: 'settings/system', element: },
{ path: 'reports/*', element: },
{ path: 'categories/*', element: },
{ path: 'blogs/*', element: },
{ path: 'wiki/*', element: },
{ path: 'videos/*', element: },
{ path: 'doctors/*', element: },
{ path: 'pets/*', element: },
{ path: 'ui-texts/*', element: },
{ path: 'media/*', element: },
{ path: 'cms/*', element: },
{ path: 'banners/*', element: },
{ path: 'smart-advisor/*', element: },
{ path: 'testimonials/*', element: },
{ path: 'ingredients/*', element: },
{ path: 'prescriptions/*', element: },
{ path: 'b2b/*', element: },
{ path: 'wholesale/*', element: },
{ path: 'contact/*', element: },
{ path: 'tickets/*', element: },
{ path: 'reviews/*', element: },
{ path: 'faq/*', element: },
{ path: 'menu/*', element: },
{ path: 'monitoring/*', element: },
{ path: 'approvals/*', element: },
{ path: 'history/*', element: },
{ path: 'tasks/*', element: },
],
},
],
},
{
path: '*',
element: ,
},
]);