import { RolePerms } from "@nice/common";
import { Link } from "react-router-dom";
import {
    SettingOutlined,
    TeamOutlined,
    UserOutlined,
    TagsOutlined,
    SafetyOutlined
} from '@ant-design/icons';
import BaseSettingPage from "../app/admin/base-setting/page";
import DepartmentAdminPage from "../app/admin/department/page";
import RoleAdminPage from "../app/admin/role/page";
import TermAdminPage from "../app/admin/term/page";
import WithAuth from "../components/utils/with-auth";
import { CustomRouteObject } from "./types";
import StaffPage from "../app/admin/staff/page";
import AdminLayout from "../components/layout/admin/AdminLayout";

export const adminRoute: CustomRouteObject = {
    path: "admin",
    name: "系统设置",
    element: <AdminLayout></AdminLayout>,
    children: [
        {
            path: "base-setting",
            name: '基本设置',
            icon: <SettingOutlined />,
            element: (
                <WithAuth
                    options={{
                        orPermissions: [RolePerms.MANAGE_BASE_SETTING],
                    }}>
                    <BaseSettingPage></BaseSettingPage>
                </WithAuth>
            ),
            handle: {
                crumb() {
                    return (
                        <Link to={"/admin/base-setting"}>
                            基本设置
                        </Link>
                    );
                },
            },
        },
        {
            path: "department",
            name: '组织架构',
            icon: <TeamOutlined />,
            element: (
                <WithAuth
                    options={{
                        orPermissions: [RolePerms.MANAGE_ANY_DEPT],
                    }}>
                    <DepartmentAdminPage></DepartmentAdminPage>
                </WithAuth>
            ),
            handle: {
                crumb() {
                    return (
                        <Link to={"/admin/department"}>
                            组织架构
                        </Link>
                    );
                },
            },
        },
        {
            path: "staff",
            name: '用户管理',
            icon: <UserOutlined />,
            element: (
                <WithAuth
                    options={{
                        orPermissions: [
                            RolePerms.MANAGE_ANY_STAFF,
                            RolePerms.MANAGE_DOM_STAFF,
                        ],
                    }}>
                    <StaffPage></StaffPage>
                </WithAuth>
            ),
            handle: {
                crumb() {
                    return (
                        <Link to={"/admin/staff"}>用户管理</Link>
                    );
                },
            },
        },
        {
            path: "term",
            name: '分类配置',
            icon: <TagsOutlined />,
            element: (
                <WithAuth
                    options={{
                        orPermissions: [
                            RolePerms.MANAGE_ANY_TERM,
                            // RolePerms.MANAGE_DOM_TERM
                        ],
                    }}>
                    <TermAdminPage></TermAdminPage>
                </WithAuth>
            ),
            handle: {
                crumb() {
                    return <Link to={"/admin/term"}>分类配置</Link>;
                },
            },
        },
        {
            path: "role",
            name: '角色管理',
            icon: <SafetyOutlined />,
            element: (
                <WithAuth
                    options={{
                        orPermissions: [
                            RolePerms.MANAGE_ANY_ROLE,
                            RolePerms.MANAGE_DOM_ROLE,
                        ],
                    }}>
                    <RoleAdminPage></RoleAdminPage>
                </WithAuth>
            ),
            handle: {
                crumb() {
                    return <Link to={"/admin/role"}>角色管理</Link>;
                },
            },
        },
    ]
}
