admin panel progress
This commit is contained in:
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user