feat: implement comprehensive CMS dashboard for managing news, events, interviews, and one-shot pricing plans
This commit is contained in:
64
admin/src/app/actions/approval.ts
Normal file
64
admin/src/app/actions/approval.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
"use server";
|
||||
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { ContentStatus } from "@prisma/client";
|
||||
|
||||
export async function approveBlogPost(id: string) {
|
||||
try {
|
||||
await prisma.blogPost.update({
|
||||
where: { id },
|
||||
data: { status: ContentStatus.PUBLISHED }
|
||||
});
|
||||
revalidatePath("/actualites");
|
||||
revalidatePath("/blog");
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
console.error("Failed to approve blog post:", error);
|
||||
return { success: false, error: "Erreur lors de l'approbation" };
|
||||
}
|
||||
}
|
||||
|
||||
export async function approveEvent(id: string) {
|
||||
try {
|
||||
await prisma.event.update({
|
||||
where: { id },
|
||||
data: { status: ContentStatus.PUBLISHED }
|
||||
});
|
||||
revalidatePath("/actualites");
|
||||
revalidatePath("/evenements");
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
console.error("Failed to approve event:", error);
|
||||
return { success: false, error: "Erreur lors de l'approbation" };
|
||||
}
|
||||
}
|
||||
|
||||
export async function rejectBlogPost(id: string) {
|
||||
try {
|
||||
// We could delete or archive it. Let's archive it.
|
||||
await prisma.blogPost.update({
|
||||
where: { id },
|
||||
data: { status: ContentStatus.ARCHIVED }
|
||||
});
|
||||
revalidatePath("/actualites");
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
console.error("Failed to reject blog post:", error);
|
||||
return { success: false, error: "Erreur lors du rejet" };
|
||||
}
|
||||
}
|
||||
|
||||
export async function rejectEvent(id: string) {
|
||||
try {
|
||||
await prisma.event.update({
|
||||
where: { id },
|
||||
data: { status: ContentStatus.ARCHIVED }
|
||||
});
|
||||
revalidatePath("/actualites");
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
console.error("Failed to reject event:", error);
|
||||
return { success: false, error: "Erreur lors du rejet" };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user