import { lazy } from 'react';

// project import
import Loadable from 'components/Loadable';

import {isGranted, isGrantedAny} from "auth/utils";
const MainLayout = Loadable(lazy(() => import('layout/MainLayout')));

const SettingPage = Loadable(lazy(() => import('pages/pnspsSettingPage')));
const PasswordPolicyPage = Loadable(lazy(()=> import('pages/pnspsPasswordPolicyPage')))
const UserSearchPage = Loadable(lazy(()=>import ('pages/User/SearchPage')));
const UserMaintainPage = Loadable(lazy(() => import('pages/User/DetailPage')));
const UserSearchPage_Individual= Loadable(lazy(()=>import ('pages/User/SearchPage_Individual')));
const UserMaintainPage_Individual = Loadable(lazy(() => import('pages/User/DetailsPage_Individual')));
const UserSearchPage_Organization= Loadable(lazy(()=>import ('pages/User/SearchPage_Organization')));
const UserMaintainPage_Organization = Loadable(lazy(() => import('pages/User/DetailsPage_Organization')));
const UserGroupSearchPage = Loadable(lazy(() => import('pages/pnspsUserGroupSearchPage')));
const UserGroupDetailPage = Loadable(lazy(() => import('pages/pnspsUserGroupDetailPage')));
const OrganizationSearchPage = Loadable(lazy(() => import('pages/Organization/SearchPage')));
const OrganizationDetailPage = Loadable(lazy(() => import('pages/Organization/DetailPage')));
const OrganizationDetailPage_fromUser = Loadable(lazy(() => import('pages/Organization/DetailPage_FromUser')));


// ==============================|| AUTH ROUTING ||============================== //

const SettingRoutes = {
    path: '/',
    element: <MainLayout />,
    children: [
        isGrantedAny(["VIEW_GROUP","MAINTAIN_GROUP"])?
        {
          path: 'usergroupSearchview',
          element: <UserGroupSearchPage />
        }:{},

        isGrantedAny(["VIEW_GROUP","MAINTAIN_GROUP"])?
        {
            path: '/userGroup/:id',
            element: <UserGroupDetailPage />
        }:{},

        isGrantedAny(["VIEW_USER","MAINTAIN_USER","VIEW_GLD_USER" ,"MAINTAIN_GLD_USER"])?
        {
            path: 'userSearchview',
            element: <UserSearchPage />
        }:{},

        isGrantedAny(["VIEW_USER","MAINTAIN_USER","VIEW_GLD_USER" ,"MAINTAIN_GLD_USER"])?
        {
            path: '/user/:id',
            element: <UserMaintainPage />
        }:{},

        isGrantedAny(["VIEW_USER","MAINTAIN_USER","VIEW_IND_USER", "MAINTAIN_IND_USER"])?
        {
            path: 'indUser',
            element: <UserSearchPage_Individual />
        }:{},

        isGrantedAny(["VIEW_USER","MAINTAIN_USER","VIEW_IND_USER", "MAINTAIN_IND_USER"])?
        {
            path: '/indUser/:id',
            element: <UserMaintainPage_Individual />
        }:{},

        isGrantedAny(["VIEW_USER","MAINTAIN_USER","VIEW_ORG_USER", "MAINTAIN_ORG_USER"])?
        {
            path: 'orgUser',
            element: <UserSearchPage_Organization />
        }:{},

        isGrantedAny(["VIEW_USER","MAINTAIN_USER","VIEW_ORG_USER", "MAINTAIN_ORG_USER"])?
        {
            path: '/orgUser/:id',
            element: <UserMaintainPage_Organization />
        }:{},

        isGrantedAny(["VIEW_ORG","MAINTAIN_ORG"])?
        {
            path: 'org',
            element: <OrganizationSearchPage />
        }:{},

        isGrantedAny(["VIEW_ORG","MAINTAIN_ORG"])?
        {
            path: '/org/:id',
            element: <OrganizationDetailPage />
        }:{},

        isGranted(["VIEW_USER","MAINTAIN_ORG"]) || isGranted(["MAINTAIN_USER","MAINTAIN_ORG"])?
        {
            path: '/org/fromUser/:id',
            element: <OrganizationDetailPage_fromUser />
        }:{},

        {
            path: 'setting',
            element: <SettingPage />
        },
        {
            path: 'passwordpolicy',
            element: <PasswordPolicyPage />
        },
       
    ]
};

export default SettingRoutes;
