mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-07-25 13:00:24 +08:00
System config parameter view
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { useRouter } from "next/router";
|
||||
import { useSession } from "next-auth/react";
|
||||
import { ReactNode, useEffect } from "react";
|
||||
|
||||
export const AdminArea = ({ children }: { children: ReactNode }) => {
|
||||
const router = useRouter();
|
||||
const { data: session, status } = useSession();
|
||||
|
||||
useEffect(() => {
|
||||
if (status === "loading") {
|
||||
return;
|
||||
}
|
||||
if (session?.user.role === "admin") {
|
||||
return;
|
||||
}
|
||||
router.push("/");
|
||||
}, [router, session, status]);
|
||||
return <main>{status === "loading" ? "loading..." : children}</main>;
|
||||
};
|
||||
@@ -1,7 +1,7 @@
|
||||
// https://nextjs.org/docs/basic-features/layouts
|
||||
|
||||
import { Box, Grid } from "@chakra-ui/react";
|
||||
import { Activity, BarChart2, Layout, MessageSquare, Users } from "lucide-react";
|
||||
import { Activity, BarChart2, Layout, MessageSquare, Settings, Users } from "lucide-react";
|
||||
import type { NextPage } from "next";
|
||||
import { Header } from "src/components/Header";
|
||||
|
||||
@@ -37,19 +37,16 @@ export const getDashboardLayout = (page: React.ReactElement) => (
|
||||
{
|
||||
label: "Dashboard",
|
||||
pathname: "/dashboard",
|
||||
desc: "Dashboard Home",
|
||||
icon: Layout,
|
||||
},
|
||||
{
|
||||
label: "Messages",
|
||||
pathname: "/messages",
|
||||
desc: "Messages Dashboard",
|
||||
icon: MessageSquare,
|
||||
},
|
||||
{
|
||||
label: "Leaderboard",
|
||||
pathname: "/leaderboard",
|
||||
desc: "User Leaderboard",
|
||||
icon: BarChart2,
|
||||
},
|
||||
]}
|
||||
@@ -72,15 +69,18 @@ export const getAdminLayout = (page: React.ReactElement) => (
|
||||
{
|
||||
label: "Users",
|
||||
pathname: "/admin",
|
||||
desc: "Users Dashboard",
|
||||
icon: Users,
|
||||
},
|
||||
{
|
||||
label: "Status",
|
||||
pathname: "/admin/status",
|
||||
desc: "Status Dashboard",
|
||||
icon: Activity,
|
||||
},
|
||||
{
|
||||
label: "Parameters",
|
||||
pathname: "/admin/parameters",
|
||||
icon: Settings,
|
||||
},
|
||||
]}
|
||||
>
|
||||
{page}
|
||||
|
||||
@@ -6,7 +6,6 @@ import { useRouter } from "next/router";
|
||||
export interface MenuButtonOption {
|
||||
label: string;
|
||||
pathname: string;
|
||||
desc: string;
|
||||
icon: LucideIcon;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user