This commit is contained in:
Andreas 2024-07-06 23:59:07 +02:00
parent a2c0736c54
commit 266ad69c97
2 changed files with 11 additions and 13 deletions

View File

@ -5,6 +5,7 @@ import Sidebar, { SidebarEntry } from "@/components/server/admin/views/sidebar";
import { ProjectView } from "@/components/views/admin/project"; import { ProjectView } from "@/components/views/admin/project";
import { PostView } from "@/components/views/admin/post"; import { PostView } from "@/components/views/admin/post";
import { redirect } from 'next/navigation' import { redirect } from 'next/navigation'
import { ReactNode } from "react";
function Home() { function Home() {
return <div>home</div>; return <div>home</div>;
@ -16,12 +17,10 @@ function ProjectManager() {
return <ProjectView></ProjectView>; return <ProjectView></ProjectView>;
} }
async function getViewMap(): Promise<Map<string, JSX.Element>> { const viewMapRecords: Record<string, ReactNode> = {
return new Map([ "home": <Home key={0}/>,
["home", <Home key={0}></Home>], "man-post": <PostManager key={1}/>,
["man-post", <PostManager key={1}></PostManager>], "man-proj": <ProjectManager key={2}/>
["man-proj", <ProjectManager key={2}></ProjectManager>],
]);
} }
const sidebarEntries: SidebarEntry[] = [ const sidebarEntries: SidebarEntry[] = [
@ -32,10 +31,9 @@ const sidebarEntries: SidebarEntry[] = [
{ label: "User Management", view: "man-user" }, { label: "User Management", view: "man-user" },
]; ];
async function getCurrentView(view: string): Promise<JSX.Element> { function getCurrentView(view: string): ReactNode {
const viewMap = await getViewMap(); const viewJSX = viewMapRecords[view || "home"];
const viewJSX = viewMap.get(view || "home"); return viewJSX;
return viewJSX || <Home></Home>;
} }
type Props = { type Props = {
@ -58,7 +56,7 @@ export default async function Page({ params: { slug = ["home"] } }: Props) {
slug={slug.toString()} slug={slug.toString()}
></Sidebar> ></Sidebar>
<div className="AdminPanelWrapper flex flex-col p-2"> <div className="AdminPanelWrapper flex flex-col p-2">
{await getCurrentView(slug.toString())} {getCurrentView(slug.toString())}
</div> </div>
</AuthHandler> </AuthHandler>
{/* <section>{JSON.stringify(cookies().getAll())}</section> */} {/* <section>{JSON.stringify(cookies().getAll())}</section> */}

View File

@ -16,9 +16,9 @@ import { handleActionResult } from "@/app/lib/actions/clientActionHandler";
import { import {
getPostsWithBucketsAndProject, getPostsWithBucketsAndProject,
GetPostsAttributes, GetPostsAttributes,
} from "@/app/lib/actions/entityManagement/post/postActions"; } from "@/app/lib/actions/entitymanagement/post/postActions";
import { PostViewProps } from "@/views/admin/post"; import { PostViewProps } from "@/components/views/admin/post";
import { StateHook } from "@/util/"; import { StateHook } from "@/util/";
export type PostTableStateProps = { export type PostTableStateProps = {