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
+10 -1
View File
@@ -1,9 +1,12 @@
'use server';
import { revalidatePath, revalidateTag } from 'next/cache'
import { Post } from "@/model/Post";
import { Attributes } from "@sequelize/core";
import { Attributes, where } from "@sequelize/core";
export async function deletePost(postID: number): Promise<boolean> {
revalidatePath("/admin/man-post","page")
const destroy = await Post.destroy({ where: { id: postID } });
return true;
}
@@ -13,3 +16,9 @@ export async function getPosts(): Promise<string> {
const posts = await Post.findAll();
return JSON.stringify(posts);
}
export async function updatePost(postAttributes: Partial<Attributes<Post>>): Promise<string> {
revalidatePath("/admin/man-post","page")
const post = await Post.update(postAttributes, {where:{id:postAttributes.id}});
return JSON.stringify(post);
}
+7
View File
@@ -0,0 +1,7 @@
'use server';
import { Project } from "@/model/Project";
export async function getProjects(): Promise<string> {
const posts = await Project.findAll();
return JSON.stringify(posts);
}