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';
import { element } from 'prop-types';

// 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')));
const Login = Loadable(lazy(() => import('pages/nearle/login')));

const Customers = Loadable(lazy(() => import('pages/nearle/clients/customers')));

const Locations = Loadable(lazy(() => import('pages/nearle/locations/Locations')));

const Orders = Loadable(lazy(() => import('pages/nearle/orders/orders')));
const Deliveries = Loadable(lazy(() => import('pages/nearle/deliveries/deliveries')));
const OrdersPreview = Loadable(lazy(() => import('pages/nearle/orders/OrdersPreview')));
const Details = Loadable(lazy(() => import('pages/nearle/orders/details')));

const Accountsettings = Loadable(lazy(() => import('pages/nearle/accountsettings')));

// const Createorder = Loadable(lazy(() => import('pages/nearle/orders/createorder')));
const CreateCustomer = Loadable(lazy(() => import('pages/nearle/clients/createCustomer')));

const Createorder1 = Loadable(lazy(() => import('pages/nearle/orders/createorder1')));
const MultipleOrders = Loadable(lazy(() => import('pages/nearle/orders/multipleOrders')));

const OrderSummary = Loadable(lazy(() => import('pages/nearle/reports/orderSummary')));
const OrdersDetails = Loadable(lazy(() => import('pages/nearle/reports/ordersDetails')));
const RiderSummary = Loadable(lazy(() => import('pages/nearle/reports/ridersummary')));
const RiderLogs = Loadable(lazy(() => import('pages/nearle/reports/riderLogs')));

const Invoice = Loadable(lazy(() => import('pages/nearle/invoice/invoice')));
const InvoicePreview = Loadable(lazy(() => import('../pages/nearle/invoice/invoicePreview')));

const Dispatch = Loadable(lazy(() => import('pages/nearle/dispatch/Dispatch')));
const DispatchPreview = Loadable(lazy(() => import('pages/nearle/dispatch/Preview')));

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

const MainRoutes = {
  path: '/',
  children: [
    {
      path: '/',
      element: (
        // <AuthGuard>
        <MainLayout />
        // </AuthGuard>
      ),
      children: [
        {
          path: 'nearle',
          children: [
            {
              path: 'orders',
              children: [
                {
                  path: '',
                  element: <Orders />
                },
                {
                  path: 'preview',
                  element: <OrdersPreview />
                },
                {
                  path: 'create/grouporders',
                  element: <MultipleOrders />
                },
                {
                  path: 'create',
                  element: <Createorder1 />
                }
              ]
            },
            {
              path: 'deliveries',
              element: <Deliveries />
            },
            {
              path: 'customers',
              children: [
                {
                  path: '',
                  element: <Customers />
                },
                {
                  path: 'create',
                  element: <CreateCustomer />
                }
              ]
            },
            {
              path: 'reports',
              children: [
                {
                  path: 'ordersummary',
                  element: <OrderSummary />
                },
                {
                  path: 'ordersdetails',
                  element: <OrdersDetails />
                },
                {
                  path: 'ridersummary',
                  element: <RiderSummary />
                },
                {
                  path: 'riderlogs',
                  element: <RiderLogs />
                }
              ]
            },
            {
              path: 'invoice',
              children: [
                {
                  path: '',
                  element: <Invoice />
                },
                {
                  path: 'preview',
                  element: <InvoicePreview />
                }
              ]
            },
            {
              path: 'locations',
              element: <Locations />
            },
            {
              path: 'dispatch',
              children: [
                {
                  path: '',
                  element: <Dispatch />
                },
                {
                  path: 'preview',
                  element: <DispatchPreview />
                }
              ]
            }
          ]
        },

        {
          path: 'accountsettings',
          element: <Accountsettings />
        },

        {
          path: 'orders/details',
          element: <Details />
        }
      ]
    },

    {
      path: '/login',
      element: <Login />
    },
    {
      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;
