feat: implement admin dashboard with authentication, menu management, and responsive UI components

This commit is contained in:
Michael committed 2026-04-10 10:43:04 +02:00
1 parent 1de5448e55
commit 5ff4784596
11 files changed
+668 -254

No files matched your search

+9
View File
@@ -4,6 +4,7 @@ import { prisma } from '@/lib/db';
import { verifyPassword } from '@/lib/auth';
import { cookies } from 'next/headers';
import { redirect } from 'next/navigation';
import { revalidatePath } from 'next/cache';
/**
* Handle admin login.
@@ -67,6 +68,10 @@ export async function addButton(formData: FormData) {
await prisma.button.create({
data: { name, url, order: 0 },
});
// Revalidate both admin and home pages to reflect new button immediately
revalidatePath('/admin');
revalidatePath('/');
}
/**
@@ -75,4 +80,8 @@ export async function addButton(formData: FormData) {
export async function deleteButton(id: number) {
if (!(await isAuthenticated())) throw new Error('Non autorisé');
await prisma.button.delete({ where: { id } });
// Revalidate both admin and home pages to reflect deletion immediately
revalidatePath('/admin');
revalidatePath('/');
}