Refactoring

This commit is contained in:
2024-06-25 11:32:06 +02:00
parent 1e8a12789d
commit a492bf4ac0
7 changed files with 36 additions and 45 deletions
+10 -13
View File
@@ -5,7 +5,7 @@ import { constructAPIUrl } from "@/util/Utils";
import { ReactNode, useEffect } from "react";
import EntityManagementTable from "../../../client/EntityManagementTable";
import PostTable from "@/components/client/admin/PostTable";
import { deletePost, getPostsWithBuckets, updatePost } from "@/app/lib/actions/entityManagement/postActions";
import { deletePost, getPostsWithBucketsAndProject, updatePost } from "@/app/lib/actions/entityManagement/postActions";
import { getProjects } from "@/app/lib/actions/entityManagement/projectActions";
import { Bucket, Project, Post, dbSync, Attachment } from "@/model/Models";
import { tryCreateAttachment } from "@/app/api/attachment/route";
@@ -13,22 +13,20 @@ import { tryCreateAttachment } from "@/app/api/attachment/route";
type Props = {
children?:ReactNode
}
async function getHeadings(){
let headings:string[] = ['#', 'Title', 'Content', 'Project', 'CreatedAt', 'UpdatedAt']
return headings
}
export default async function PostView(props:Props){
await dbSync;
const sync = await dbSync;
const headings = await getHeadings();
const headings = [
'#',
'Title',
'Content',
'Project',
'Date Created',
'Date Modified',
]
const actions = {
deletePost: deletePost,
getPosts:getPostsWithBuckets,
getPosts:getPostsWithBucketsAndProject,
getProjects:getProjects,
savePost:updatePost,
// uploadAttachment:tryCreateAttachment
@@ -39,7 +37,6 @@ export default async function PostView(props:Props){
return (
<div className="w-[100%] min-h-fit bg-gray-100 overflow-scroll">
<span className="flex flex-row flex-grow w-[100%] pl-2 pr-2"><h1 className="p-2 inline-block">Post Management</h1><section className="flex-grow"></section><button className='btn btn-success h-12 mt-auto mb-auto self-end'>New</button></span>
<div className="w-[100%] m-auto">
<PostTable data={posts}
projects={projects}