admin panel progress

This commit is contained in:
2024-06-08 00:21:53 +02:00
parent a0a938021d
commit 99c3267c04
24 changed files with 305 additions and 103 deletions
+13 -4
View File
@@ -5,7 +5,9 @@ import { constructAPIUrl } from "@/util/Utils";
import { ReactNode, useEffect } from "react";
import TableGen from "../../../client/TableGen";
import PostTable from "@/components/client/admin/PostTable";
import { deletePost, getPosts } from "@/app/lib/postActions";
import { deletePost, getPosts, updatePost } from "@/app/lib/postActions";
import { getProjects } from "@/app/lib/projectActions";
import { Project } from "@/model/Project";
type Props = {
children?:ReactNode
@@ -17,18 +19,25 @@ export default async function PostView(props:Props){
'#',
'Title',
'Content',
'Project',
'Date Created',
'Date Modified',
'Edit',
'Delete',
]
const data = await Post.findAll();
const passData:any[] = data.map((e)=>JSON.parse(JSON.stringify(e)));
const actions = {
deletePost: deletePost,
getPosts:getPosts, getProjects:
getProjects,
savePost:updatePost
};
const posts:Post[] = await Post.findAll().then(posts=>posts.map((e)=>JSON.parse(JSON.stringify(e))));
const projects = await Project.findAll().then(projects=>projects.map((e)=>JSON.parse(JSON.stringify(e))));
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={passData} headings={headings} actions={{deletePost: deletePost, getPosts:getPosts}}></PostTable>
<PostTable data={posts} projects={projects} headings={headings} actions={actions}></PostTable>
</div>
</div>
);