import { lazy } from 'react';

// project import
import Loadable from 'components/Loadable';
// import MainLayout from 'layout/MainLayout';
const MainLayout = Loadable(lazy(() => import('layout/MainLayout')));
import {isGranted, isGrantedAny} from "auth/utils";
// import { isPasswordExpiry } from "utils/Utils";
// render - dashboard
const DashboardDefault = Loadable(lazy(() => import('pages/dashboard/GLD')));
const ApplicationDetail = Loadable(lazy(() => import('pages/PublicNotice/Details_GLD')));
const ApplicationSearch = Loadable(lazy(() => import('pages/PublicNotice/Search_GLD')));
const ApplicationMarkAsPaidSearch = Loadable(lazy(() => import('pages/PublicNotice/Search_Mark_As_Paid_GLD')));
const ProofSearch = Loadable(lazy(() => import('pages/Proof/Search_GLD')));
const ProofCreate_FromApp = Loadable(lazy(() => import('pages/Proof/Create_FromApp')));
const ProofReply_GLD = Loadable(lazy(() => import('pages/Proof/Reply_GLD')));
const PaymentSearch_GLD = Loadable(lazy(() => import('pages/Payment/Search_GLD')));
const PaymentDetails_GLD = Loadable(lazy(() => import('pages/Payment/Details_GLD')));
const DemandNote_Create = Loadable(lazy(() => import('pages/DemandNote/Create')));
const DemandNote_Export = Loadable(lazy(() => import('pages/DemandNote/Export')));
const DemandNote_Search = Loadable(lazy(() => import('pages/DemandNote/Search')));
const DemandNote_Details = Loadable(lazy(() => import('pages/DemandNote/Details')));
const GFMIS_Search = Loadable(lazy(() => import('pages/GFMIS')));
const UserMaintainPage = Loadable(lazy(() => import('pages/User/GLDUserProfile')));
const SystemSetting = Loadable(lazy(() => import('pages/Setting/SystemSetting')));
const AnnouncementDetails = Loadable(lazy(() => import('pages/Announcement/Details')));
const AnnouncementSearch = Loadable(lazy(() => import('pages/Announcement/Search')));
const EmailTemplatePage = Loadable(lazy(() => import('pages/EmailTemplate/Search_GLD')));
const EmailTemplateDetailPage = Loadable(lazy(() => import('pages/EmailTemplate/Detail_GLD')));
const HolidayPage = Loadable(lazy(() => import('pages/Holiday')));
const GazetteIssuePage = Loadable(lazy(() => import('pages/GazetteIssue/index')));
const DrImport = Loadable(lazy(() => import('pages/Setting/DrImport')));
const HkidKeyMigration = Loadable(lazy(() => import('pages/Setting/HkidKeyMigration')));
const UserPiiEncryption = Loadable(lazy(() => import('pages/Setting/UserPiiEncryption')));
const AuditLogPage = Loadable(lazy(() => import('pages/AuditLog/index')));
const ReconReportPage = Loadable(lazy(() => import('pages/Recon')));
const ChangePasswordPage = Loadable(lazy(() => import('pages/User/ChangePasswordPage')));
const JVMDefault = Loadable(lazy(() => import('pages/JVM')));
const FullListReportPage = Loadable(lazy(() => import('pages/Report/FullList')));
const SummaryReportPage = Loadable(lazy(() => import('pages/Report/Summary')));

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

const GLDUserRoutes = {
  path: '/',
  element: <MainLayout />,
  children: [
    {
      path: '/',
      element: <DashboardDefault />
    },
    {
      path: '/',
      children: [
        {
          path: '/dashboard',
          element: <DashboardDefault />
        },

        isGrantedAny(["VIEW_APPLICATION","MAINTAIN_APPLICATION"])?
        {
          path: '/application/:id',
          element: <ApplicationDetail/>
        }:{},

        isGrantedAny(["VIEW_APPLICATION","MAINTAIN_APPLICATION"])?
        {
          path: '/application/search',
          element: <ApplicationSearch/>
        }:{},

        isGranted(["MAINTAIN_PAYMENT"])?
        {
          path: '/application/markAsPaid/search',
          element: <ApplicationMarkAsPaidSearch/>
        }:{},

        isGrantedAny(["VIEW_PROOF","MAINTAIN_PROOF"])?{
          path: '/proof/search',
          element: <ProofSearch/>
        }:{},

        isGranted("MAINTAIN_PROOF")?
        {
          path: '/proof/create/:id',
          element: <ProofCreate_FromApp/>
        }:{},

        isGrantedAny(["VIEW_PROOF","MAINTAIN_PROOF"])?{
          path: '/proof/reply/:id',
          element: <ProofReply_GLD/>
        }:{},

        isGranted(["MAINTAIN_PAYMENT"])?
        {
          path: '/paymentPage/search',
          element: <PaymentSearch_GLD/>
        }:{},
        
        isGranted(["MAINTAIN_PAYMENT"])?
        {
          path: '/paymentPage/details/:id',
          element: <PaymentDetails_GLD/>
        }:{},

        isGranted(["MAINTAIN_DEMANDNOTE"])?
        {
          path: '/paymentPage/createDemandNote',
          element: <DemandNote_Create/>
        }:{},

        isGranted(["MAINTAIN_PROOF"])?
        {
          path: '/paymentPage/exportGDN',
          element: <DemandNote_Export/>
        }:{},

        isGrantedAny(["VIEW_DEMANDNOTE","MAINTAIN_DEMANDNOTE"])?
        {
          path: '/paymentPage/demandNote',
          element: <DemandNote_Search/>
        }:{},

        isGrantedAny(["VIEW_DEMANDNOTE","MAINTAIN_DEMANDNOTE"])?
        {
          path: '/paymentPage/demandNote/details/:id',
          element: <DemandNote_Details/>
        }:{},

        isGranted("MAINTAIN_RECON") ?
        {
          path: '/paymentPage/reconReport',
          element: <ReconReportPage/>
        }:{},

        isGranted("MAINTAIN_RECON") ?
        {
          path: '/gfmis/search',
          element: <GFMIS_Search/>
        }:{},

        {
          path: '/user/profile',
          element: <UserMaintainPage />
        },

        isGranted("MAINTAIN_SETTING") ?
        {
          path: '/setting/sys',
          element: <SystemSetting />
        }:{},

        isGranted("MAINTAIN_ANNOUNCEMENT") ?
        {
          path: '/setting/announcement',
          element: <AnnouncementSearch />
        }:{},

        isGranted("MAINTAIN_ANNOUNCEMENT")?
        {
          path: '/setting/announcement/details/:id',
          element: <AnnouncementDetails />
        }:{},

        isGranted("MAINTAIN_EMAIL")?
        {
          path: '/setting/emailTemplate',
          element: <EmailTemplatePage/>
        }:{},

        isGranted("MAINTAIN_EMAIL")?
        {
            path: '/setting/emailTemplate/:id',
            element: <EmailTemplateDetailPage/>
        }:{},

        isGrantedAny(["VIEW_GAZETTE_ISSUE","MAINTAIN_GAZETTE_ISSUE"])?
        {
            path: '/setting/holiday',
            element: <HolidayPage/>
        }:{},

        isGrantedAny(["VIEW_GAZETTE_ISSUE","MAINTAIN_GAZETTE_ISSUE"])?
        {
            path: '/setting/gazetteissuepage',
            element: <GazetteIssuePage/>
        }:{},

        isGranted("MAINTAIN_DR")?
        {
          path: '/setting/drImport',
          element: <DrImport />
        }:{},

        isGranted("MAINTAIN_SETTING")?
        {
          path: '/setting/hkidKeyMigration',
          element: <HkidKeyMigration />
        }:{},

        isGranted("MAINTAIN_SETTING")?
        {
          path: '/setting/userPiiEncryption',
          element: <UserPiiEncryption />
        }:{},

        isGranted("MAINTAIN_SETTING")?
        {
          path: '/setting/auditLog',
          element: <AuditLogPage />
        }:{},
        isGranted("MAINTAIN_SETTING")?
        {
          path: '/sys-status',
          element: <JVMDefault />
        }:{},

        {
          path: '/user/changePassword',
          element: <ChangePasswordPage />
        },
        {
            path: '/setting/report/fullList',
            element: <FullListReportPage />
        },
        {
            path: '/setting/report/summary',
            element: <SummaryReportPage/>
        },
      ]
    }
  ]
};

export default GLDUserRoutes;
