More refactoring
This commit is contained in:
parent
1971966099
commit
772395ae1a
@ -2,8 +2,8 @@
|
||||
cache: "no-store";
|
||||
import AuthHandler from "@/components/server/admin/authHandler";
|
||||
import Sidebar, { SidebarEntry } from "@/components/server/admin/views/sidebar";
|
||||
import ProjectView from "@/views/admin/ProjectView";
|
||||
import PostView from "@/views/admin/PostView";
|
||||
import { ProjectView } from "@/views/admin/project";
|
||||
import { PostView } from "@/views/admin/post";
|
||||
import { redirect } from 'next/navigation'
|
||||
|
||||
function Home() {
|
||||
|
||||
@ -1,16 +0,0 @@
|
||||
import { AuthContext } from "@/providers/providers";
|
||||
import { ReactNode, useContext } from "react"
|
||||
|
||||
type Props = {
|
||||
children:ReactNode;
|
||||
}
|
||||
|
||||
|
||||
|
||||
export default function AdminOnlyComponent(p:Props){
|
||||
const context = useContext(AuthContext)
|
||||
return
|
||||
(<div>
|
||||
|
||||
</div>);
|
||||
}
|
||||
@ -18,7 +18,7 @@ import {
|
||||
GetPostsAttributes,
|
||||
PostServerActions,
|
||||
} from "@/app/lib/actions/entityManagement/post/postActions";
|
||||
import { PostViewProps } from "@/views/admin/ClientPostView";
|
||||
import { PostViewProps } from "@/views/admin/post";
|
||||
import { aifa } from "@/util/utils";
|
||||
import { StateHook } from "@/util/state";
|
||||
|
||||
|
||||
@ -1,61 +0,0 @@
|
||||
'use server'
|
||||
cache: "no-store";
|
||||
|
||||
import { ReactNode, useEffect } from "react";
|
||||
import PostTable from "@/components/client/admin/PostTable";
|
||||
import {
|
||||
deletePost,
|
||||
getPostsWithBucketsAndProject,
|
||||
updatePost,
|
||||
GetPostsAttributes,
|
||||
PostServerActions,
|
||||
} from "@/app/lib/actions/entityManagement/post/postActions";
|
||||
import { getProjects } from "@/app/lib/actions/entityManagement/post/projectActions";
|
||||
import { Bucket, Project, Post, dbSync, Attachment } from "@/models";
|
||||
import { handleActionResult } from "../../app/lib/actions/clientActionHandler";
|
||||
import { ClientPostView } from "./ClientPostView";
|
||||
|
||||
type Props = {
|
||||
children?: ReactNode;
|
||||
};
|
||||
|
||||
export default async function PostView(props: Props) {
|
||||
const sync = await dbSync;
|
||||
|
||||
const headings:string[] = [
|
||||
"#",
|
||||
"Title",
|
||||
"Content",
|
||||
"Project",
|
||||
"CreatedAt",
|
||||
"UpdatedAt",
|
||||
];
|
||||
|
||||
const actions: PostServerActions = {
|
||||
deletePost: deletePost,
|
||||
getPosts: getPostsWithBucketsAndProject,
|
||||
getProjects: getProjects,
|
||||
savePost: updatePost,
|
||||
// uploadAttachment:tryCreateAttachment
|
||||
};
|
||||
|
||||
const posts: GetPostsAttributes[]| undefined = handleActionResult(
|
||||
await getPostsWithBucketsAndProject()
|
||||
);
|
||||
const projects = await Project.findAll().then((projects) =>
|
||||
projects.map((project) => JSON.parse(JSON.stringify(project)))
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="w-[100%] min-h-fit bg-gray-100 overflow-scroll">
|
||||
<div className="w-[100%] m-auto">
|
||||
<ClientPostView
|
||||
posts={posts ? posts : []}
|
||||
projects={projects}
|
||||
headings={headings}
|
||||
actions={actions}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
61
src/views/admin/post/PostView.tsx
Normal file
61
src/views/admin/post/PostView.tsx
Normal file
@ -0,0 +1,61 @@
|
||||
"use server";
|
||||
cache: "no-store";
|
||||
|
||||
import { ReactNode, useEffect } from "react";
|
||||
import PostTable from "@/components/client/admin/PostTable";
|
||||
import {
|
||||
deletePost,
|
||||
getPostsWithBucketsAndProject,
|
||||
updatePost,
|
||||
GetPostsAttributes,
|
||||
PostServerActions,
|
||||
} from "@/app/lib/actions/entityManagement/post/postActions";
|
||||
import { getProjects } from "@/app/lib/actions/entityManagement/post/projectActions";
|
||||
import { Bucket, Project, Post, dbSync, Attachment } from "@/models";
|
||||
import { handleActionResult } from "@/app/lib/actions/clientActionHandler";
|
||||
import { ClientPostView } from "@/views/admin/post";
|
||||
|
||||
type Props = {
|
||||
children?: ReactNode;
|
||||
};
|
||||
|
||||
export async function PostView(props: Props) {
|
||||
const sync = await dbSync;
|
||||
|
||||
const headings: string[] = [
|
||||
"#",
|
||||
"Title",
|
||||
"Content",
|
||||
"Project",
|
||||
"CreatedAt",
|
||||
"UpdatedAt",
|
||||
];
|
||||
|
||||
const actions: PostServerActions = {
|
||||
deletePost: deletePost,
|
||||
getPosts: getPostsWithBucketsAndProject,
|
||||
getProjects: getProjects,
|
||||
savePost: updatePost,
|
||||
// uploadAttachment:tryCreateAttachment
|
||||
};
|
||||
|
||||
const posts: GetPostsAttributes[] | undefined = handleActionResult(
|
||||
await getPostsWithBucketsAndProject()
|
||||
);
|
||||
const projects = await Project.findAll().then((projects) =>
|
||||
projects.map((project) => JSON.parse(JSON.stringify(project)))
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="w-[100%] min-h-fit bg-gray-100 overflow-scroll">
|
||||
<div className="w-[100%] m-auto">
|
||||
<ClientPostView
|
||||
posts={posts ? posts : []}
|
||||
projects={projects}
|
||||
headings={headings}
|
||||
actions={actions}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
2
src/views/admin/post/index.ts
Normal file
2
src/views/admin/post/index.ts
Normal file
@ -0,0 +1,2 @@
|
||||
export * from './ClientPostView';
|
||||
export * from './PostView';
|
||||
0
src/views/admin/project/CProjectView.tsx
Normal file
0
src/views/admin/project/CProjectView.tsx
Normal file
@ -1,9 +1,7 @@
|
||||
cache: "no-store";
|
||||
|
||||
import { tryFetchPosts } from "@/app/api/post/route";
|
||||
import { constructAPIUrl } from "@/util/utils";
|
||||
import { ReactNode, useEffect } from "react";
|
||||
import EntityManagementTable from "../../components/client/EntityManagementTable";
|
||||
import EntityManagementTable from "../../../components/client/EntityManagementTable";
|
||||
import PostTable from "@/components/client/admin/PostTable";
|
||||
import {
|
||||
deletePost,
|
||||
@ -28,7 +26,7 @@ async function getHeadings() {
|
||||
return headings;
|
||||
}
|
||||
|
||||
export default async function ProjectView(props: Props) {
|
||||
export async function ProjectView(props: Props) {
|
||||
const sync = await dbSync;
|
||||
|
||||
const actions = {
|
||||
2
src/views/admin/project/index.ts
Normal file
2
src/views/admin/project/index.ts
Normal file
@ -0,0 +1,2 @@
|
||||
export * from './CProjectView';
|
||||
export * from './ProjectView';
|
||||
0
src/views/admin/template/CTemplateView.tsx
Normal file
0
src/views/admin/template/CTemplateView.tsx
Normal file
0
src/views/admin/template/TemplateView.tsx
Normal file
0
src/views/admin/template/TemplateView.tsx
Normal file
Loading…
x
Reference in New Issue
Block a user