fixes
This commit is contained in:
parent
a2c0736c54
commit
266ad69c97
@ -5,6 +5,7 @@ import Sidebar, { SidebarEntry } from "@/components/server/admin/views/sidebar";
|
||||
import { ProjectView } from "@/components/views/admin/project";
|
||||
import { PostView } from "@/components/views/admin/post";
|
||||
import { redirect } from 'next/navigation'
|
||||
import { ReactNode } from "react";
|
||||
|
||||
function Home() {
|
||||
return <div>home</div>;
|
||||
@ -16,12 +17,10 @@ function ProjectManager() {
|
||||
return <ProjectView></ProjectView>;
|
||||
}
|
||||
|
||||
async function getViewMap(): Promise<Map<string, JSX.Element>> {
|
||||
return new Map([
|
||||
["home", <Home key={0}></Home>],
|
||||
["man-post", <PostManager key={1}></PostManager>],
|
||||
["man-proj", <ProjectManager key={2}></ProjectManager>],
|
||||
]);
|
||||
const viewMapRecords: Record<string, ReactNode> = {
|
||||
"home": <Home key={0}/>,
|
||||
"man-post": <PostManager key={1}/>,
|
||||
"man-proj": <ProjectManager key={2}/>
|
||||
}
|
||||
|
||||
const sidebarEntries: SidebarEntry[] = [
|
||||
@ -32,10 +31,9 @@ const sidebarEntries: SidebarEntry[] = [
|
||||
{ label: "User Management", view: "man-user" },
|
||||
];
|
||||
|
||||
async function getCurrentView(view: string): Promise<JSX.Element> {
|
||||
const viewMap = await getViewMap();
|
||||
const viewJSX = viewMap.get(view || "home");
|
||||
return viewJSX || <Home></Home>;
|
||||
function getCurrentView(view: string): ReactNode {
|
||||
const viewJSX = viewMapRecords[view || "home"];
|
||||
return viewJSX;
|
||||
}
|
||||
|
||||
type Props = {
|
||||
@ -58,7 +56,7 @@ export default async function Page({ params: { slug = ["home"] } }: Props) {
|
||||
slug={slug.toString()}
|
||||
></Sidebar>
|
||||
<div className="AdminPanelWrapper flex flex-col p-2">
|
||||
{await getCurrentView(slug.toString())}
|
||||
{getCurrentView(slug.toString())}
|
||||
</div>
|
||||
</AuthHandler>
|
||||
{/* <section>{JSON.stringify(cookies().getAll())}</section> */}
|
||||
|
||||
@ -16,9 +16,9 @@ import { handleActionResult } from "@/app/lib/actions/clientActionHandler";
|
||||
import {
|
||||
getPostsWithBucketsAndProject,
|
||||
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/";
|
||||
|
||||
export type PostTableStateProps = {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user