import {lazy, useContext} from 'react';

// project import
import Loadable from 'components/Loadable';
import MainLayout from 'layout/MainLayout';
import AbilityContext from "../components/AbilityProvider";
import {handleRouteAbility} from "../utils/CommonFunction";
import {Navigate} from "react-router";
import ClientSearchPage from 'pages/client/ClientSearchPage/index';

// render - dashboard
//const DashboardDefault = Loadable(lazy(() => import('pages/dashboard')));
const LIONERDashboard = Loadable(lazy(() => import('pages/lionerdashboard')));
const ReminderPage = Loadable(lazy(() => import('pages/lionerReminderPage')));
const TemplateSearchPage = Loadable(lazy(() => import('pages/lionerSearchPanel')));
const TemplateMaintainPage = Loadable(lazy(() => import('pages/lionerMaintainSearchTemplatePage')));

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

// render - utilities
// const Typography = Loadable(lazy(() => import('pages/components-overview/Typography')));
// const Color = Loadable(lazy(() => import('pages/components-overview/Color')));
// const Shadow = Loadable(lazy(() => import('pages/components-overview/Shadow')));
// const AntIcons = Loadable(lazy(() => import('pages/components-overview/AntIcons')));

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

const MainRoutes = () => {
  const ability = useContext(AbilityContext);

  return {
    path: '/',
    element: <MainLayout/>,
    children: [
      {
        path: '/',
        element:  (
            handleRouteAbility(
                ability.can('VIEW', 'CLIENT'),
                <ClientSearchPage />,
                <Navigate to="/" />
            )
        ),
      },
      {
        path: '/lionerDashboard',
        element:  (
            handleRouteAbility(
                ability.can('VIEW', 'CLIENT'),
                <ClientSearchPage />,
                // <LIONERDashboard />,
                <Navigate to="/client" />
            )
        ),
      },
      
      // {
      //   path: '/reminder',
      //   element:  (
      //       handleRouteAbility(
      //           ability.can('VIEW', 'REMINDER'),
      //           <ReminderPage />,
      //           <Navigate to="/lionerDashboard" />
      //       )
      //   ),
      // },
      // {
      //   path: '/template',
      //   element:  (
      //       handleRouteAbility(
      //           ability.can('MAINTAIN', 'SEARCH_TEMPLATE'),
      //           <TemplateSearchPage />,
      //           <Navigate to="/lionerDashboard" />
      //       )
      //   ),
      // },
      // {
      //   path: '/template/maintain/:id',
      //   element:  (
      //       handleRouteAbility(
      //           ability.can('MAINTAIN', 'SEARCH_TEMPLATE'),
      //           <TemplateMaintainPage />,
      //           <Navigate to="/lionerDashboard" />
      //       )
      //   ),
      // },
    ]
  };
}

export default MainRoutes;
