import { lazy } from 'react';

// project import
import MainLayout from 'layout/MainLayout';
import CommonLayout from 'layout/CommonLayout';
import Loadable from 'components/Loadable';
import AuthGuard from 'utils/route-guard/AuthGuard';

// pages routing
const MaintenanceError = Loadable(lazy(() => import('pages/maintenance/404')));
const MaintenanceError500 = Loadable(lazy(() => import('pages/maintenance/500')));
const MaintenanceUnderConstruction = Loadable(lazy(() => import('pages/maintenance/under-construction')));
const MaintenanceComingSoon = Loadable(lazy(() => import('pages/maintenance/coming-soon')));

// render - sample page
// const SamplePage = Loadable(lazy(() => import('pages/extra-pages/sample-page')));

// render - nearle pages
const Dashboard = Loadable(lazy(() => import('pages/nearle_pages/dashboard')));
const Orders = Loadable(lazy(() => import('pages/nearle_pages/orders')));
const Deliveries = Loadable(lazy(() => import('pages/nearle_pages/deliveries')));
const Catalogue = Loadable(lazy(() => import('pages/nearle_pages/catalogue')));
const Products = Loadable(lazy(() => import('pages/nearle_pages/products')));
const Locations = Loadable(lazy(() => import('pages/nearle_pages/Locations')));
const Customers = Loadable(lazy(() => import('pages/nearle_pages/Customers')));
const Users = Loadable(lazy(() => import('pages/nearle_pages/users/Users')));
const Api = Loadable(lazy(() => import('pages/nearle_pages/api')));
const Statements = Loadable(lazy(() => import('pages/nearle_pages/reports/statements')));
const OrderDetails = Loadable(lazy(() => import('pages/nearle_pages/reports/orderdetails')));

// render - old pages (commented)
// const OldDashboard = Loadable(lazy(() => import('pages/extra-pages/dashboard')));
// const Items = Loadable(lazy(() => import('pages/extra-pages/items')));
// const RiderReports = Loadable(lazy(() => import('pages/extra-pages/rider-reports')));
// const OrderReports = Loadable(lazy(() => import('pages/extra-pages/order-reports')));
// const CustomerReports = Loadable(lazy(() => import('pages/extra-pages/customer-reports')));

// ==============================|| MAIN ROUTING ||============================== //

const MainRoutes = {
  path: '/',
  children: [
    {
      path: '/',
      element: (
        <AuthGuard>
          <MainLayout />
        </AuthGuard>
      ),
      children: [
        // {
        //   path: 'sample-page',
        //   element: <SamplePage />
        // },
        {
          index: true,
          element: <Dashboard />
        },
        {
          path: 'dashboard',
          element: <Dashboard />
        },
        {
          path: 'orders',
          element: <Orders />
        },
        {
          path: 'deliveries',
          element: <Deliveries />
        },
        {
          path: 'catalogue',
          element: <Catalogue />
        },
        {
          path: 'products',
          element: <Products />
        },
        {
          path: 'locations',
          element: <Locations />
        },
        {
          path: 'customers',
          element: <Customers />
        },
        {
          path: 'users',
          element: <Users />
        },
        {
          path: 'api',
          element: <Api />
        },
        {
          path: 'statements',
          element: <Statements />
        },
        {
          path: 'orderdetails',
          element: <OrderDetails />
        }
        // old routes commented
        // {
        //   path: 'items',
        //   element: <Items />
        // },
        // {
        //   path: 'rider-reports',
        //   element: <RiderReports />
        // },
        // {
        //   path: 'order-reports',
        //   element: <OrderReports />
        // },
        // {
        //   path: 'customer-reports',
        //   element: <CustomerReports />
        // }
      ]
    },
    {
      path: '/maintenance',
      element: <CommonLayout />,
      children: [
        {
          path: '404',
          element: <MaintenanceError />
        },
        {
          path: '500',
          element: <MaintenanceError500 />
        },
        {
          path: 'under-construction',
          element: <MaintenanceUnderConstruction />
        },
        {
          path: 'coming-soon',
          element: <MaintenanceComingSoon />
        }
      ]
    }
  ]
};

export default MainRoutes;
