import { Suspense, lazy } from "react";
import { createBrowserRouter } from "react-router-dom";
import App from "@/App";
import MainLayout from "@/layouts/MainLayout";
import RootLayout from "@/layouts/RootLayout";
import Home from "@/pages/Home";
import Loading from "@/pages/Loading";
const AdminSignIn = lazy(() => import("@/pages/AdminSignIn"));
const Archived = lazy(() => import("@/pages/Archived"));
const AuthCallback = lazy(() => import("@/pages/AuthCallback"));
const Explore = lazy(() => import("@/pages/Explore"));
const Inboxes = lazy(() => import("@/pages/Inboxes"));
const MemoDetail = lazy(() => import("@/pages/MemoDetail"));
const NotFound = lazy(() => import("@/pages/NotFound"));
const PermissionDenied = lazy(() => import("@/pages/PermissionDenied"));
const Attachments = lazy(() => import("@/pages/Attachments"));
const Setting = lazy(() => import("@/pages/Setting"));
const SignIn = lazy(() => import("@/pages/SignIn"));
const SignUp = lazy(() => import("@/pages/SignUp"));
const UserProfile = lazy(() => import("@/pages/UserProfile"));
const MemoDetailRedirect = lazy(() => import("./MemoDetailRedirect"));
export enum Routes {
ROOT = "/",
ATTACHMENTS = "/attachments",
INBOX = "/inbox",
ARCHIVED = "/archived",
SETTING = "/setting",
EXPLORE = "/explore",
AUTH = "/auth",
}
const router = createBrowserRouter([
{
path: "/",
element: ,
children: [
{
path: Routes.AUTH,
children: [
{
path: "",
element: (
}>
),
},
{
path: "admin",
element: (
}>
),
},
{
path: "signup",
element: (
}>
),
},
{
path: "callback",
element: (
}>
),
},
],
},
{
path: Routes.ROOT,
element: ,
children: [
{
element: ,
children: [
{
path: "",
element: ,
},
{
path: Routes.EXPLORE,
element: (
}>
),
},
{
path: Routes.ARCHIVED,
element: (
}>
),
},
{
path: "u/:username",
element: (
}>
),
},
],
},
{
path: Routes.ATTACHMENTS,
element: (
}>
),
},
{
path: Routes.INBOX,
element: (
}>
),
},
{
path: Routes.SETTING,
element: (
}>
),
},
{
path: "memos/:uid",
element: (
}>
),
},
// Redirect old path to new path.
{
path: "m/:uid",
element: (
}>
),
},
{
path: "403",
element: (
}>
),
},
{
path: "404",
element: (
}>
),
},
{
path: "*",
element: (
}>
),
},
],
},
],
},
]);
export default router;