feat: implement comprehensive CMS dashboard for managing news, events, interviews, and one-shot pricing plans

This commit is contained in:
2026-05-10 17:50:56 +02:00
parent 87b13dce13
commit 9846efd03e
40 changed files with 1487 additions and 175 deletions

View File

@@ -30,7 +30,8 @@ export async function createBlogPost(data: {
status: data.status || ContentStatus.PUBLISHED,
},
});
revalidatePath("/blog");
revalidatePath("/actualites");
revalidatePath("/");
return { success: true, id: post.id };
} catch (error) {
console.error("Failed to create blog post:", error);
@@ -62,7 +63,8 @@ export async function updateBlogPost(id: string, data: {
tags: data.tags || [],
},
});
revalidatePath("/blog");
revalidatePath("/actualites");
revalidatePath("/");
return { success: true, id: post.id };
} catch (error) {
console.error("Failed to update blog post:", error);
@@ -75,7 +77,8 @@ export async function deleteBlogPost(id: string) {
await prisma.blogPost.delete({
where: { id },
});
revalidatePath("/blog");
revalidatePath("/actualites");
revalidatePath("/");
return { success: true };
} catch (error) {
console.error("Failed to delete blog post:", error);

View 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" };
}
}

View File

@@ -0,0 +1,40 @@
"use server";
import { prisma } from "@/lib/prisma";
import { revalidatePath } from "next/cache";
import { OneShotType } from "@prisma/client";
export async function getOneShotPlans() {
try {
return await prisma.oneShotPlan.findMany({
orderBy: { type: 'asc' }
});
} catch (error) {
console.error("Failed to fetch one-shot plans:", error);
return [];
}
}
export async function updateOneShotPlan(type: OneShotType, data: {
name: string;
priceXOF: number;
priceEUR: number;
description?: string;
}) {
try {
await prisma.oneShotPlan.upsert({
where: { type },
update: data,
create: {
type,
...data
}
});
revalidatePath("/settings");
revalidatePath("/subscription");
return { success: true };
} catch (error) {
console.error("Failed to update one-shot plan:", error);
return { success: false, error: "Erreur lors de la mise à jour" };
}
}

View File

@@ -102,6 +102,8 @@ export async function searchBusinesses(query: string) {
id: true,
name: true,
logoUrl: true,
coverUrl: true,
description: true,
location: true,
}
});