import {
	createBrowserRouter,
	IndexRouteObject,
	Link,
	NonIndexRouteObject,
} from "react-router-dom";
import { RolePerms } from "@nice/common";
import ErrorPage from "../app/error";
import DepartmentAdminPage from "../app/admin/department/page";
import TermAdminPage from "../app/admin/term/page";
import StaffAdminPage from "../app/admin/staff/page";
import RoleAdminPage from "../app/admin/role/page";
import WithAuth from "../components/utils/with-auth";
import BaseSettingPage from "../app/admin/base-setting/page";
import { MainLayout } from "../components/layout/main/MainLayout";
import WriteLetterPage from "../app/main/letter/write/page";
import LetterListPage from "../app/main/letter/list/page";
import LetterProgressPage from "../app/main/letter/progress/page";
import HelpPage from "../app/main/help/page";
import AuthPage from "../app/auth/page";
import LetterEditorPage from "../app/main/letter/editor/page";
import LetterDetailPage from "../app/main/letter/detail/page";
import AdminLayout from "../components/layout/admin/AdminLayout";
import { CustomRouteObject } from "./types";
import { adminRoute } from "./admin-route";
import InboxPage from "../app/main/letter/inbox/page";
import OutboxPage from "../app/main/letter/outbox/page";
import IndexPage from "../app/main/letter/index/page";
export const routes: CustomRouteObject[] = [
	{
		path: "/",
		errorElement: <ErrorPage />,
		handle: {
			crumb() {
				return <Link to={"/"}>主页</Link>;
			},
		},
		children: [
			{
				element: <MainLayout></MainLayout>,
				children: [
					{
						path: "inbox",
						element: <InboxPage></InboxPage>,
					},
					{
						path: "outbox",
						element: <OutboxPage></OutboxPage>,
					},
					{
						index: true,
						element: <IndexPage></IndexPage>,
					},
					{
						path: "letter-list",
						element: <LetterListPage></LetterListPage>,
					},
					{
						path: ":id?/detail",
						element: <LetterDetailPage></LetterDetailPage>,
					},
					{
						path: "editor",
						element: <LetterEditorPage></LetterEditorPage>,
					},
					{
						path: "write-letter",
						element: <WriteLetterPage></WriteLetterPage>,
					},

					{
						path: "letter-progress",
						element: <LetterProgressPage></LetterProgressPage>,
					},
					{
						path: "help",
						element: <HelpPage></HelpPage>,
					},
				],
			},
			adminRoute,
		],
	},
	{
		path: "/auth",

		element: <AuthPage></AuthPage>,
	},
];

export const router = createBrowserRouter(routes);
