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

42
app/actions/events.ts Normal file
View File

@@ -0,0 +1,42 @@
"use server";
import { prisma } from "@/lib/prisma";
import { revalidatePath } from "next/cache";
import { ContentStatus } from "@prisma/client";
export async function createEvent(data: {
title: string;
description: string;
date: string;
location: string;
thumbnailUrl: string;
link?: string;
tags?: string[];
}) {
try {
const slug = data.title
.toLowerCase()
.replace(/[^a-z0-9]+/g, '-')
.replace(/(^-|-$)/g, '');
const event = await prisma.event.create({
data: {
title: data.title,
description: data.description,
date: new Date(data.date),
location: data.location,
thumbnailUrl: data.thumbnailUrl,
link: data.link || null,
tags: data.tags || [],
status: ContentStatus.PENDING, // Always pending for user submission
slug: `${slug}-${Math.random().toString(36).substring(2, 7)}`
}
});
revalidatePath("/evenements");
return { success: true, event };
} catch (error) {
console.error("Failed to create event:", error);
return { success: false, error: "Erreur lors de la création de l'événement" };
}
}