feat: implement admin dashboard with authentication and title management capabilities

This commit is contained in:
Michael committed 2026-04-10 11:45:57 +02:00
1 parent d253eff0fa
commit 0bfed1adf2
4 files changed
+115 -1

No files matched your search

+19
View File
@@ -105,3 +105,22 @@ export async function deleteButton(id: number) {
revalidatePath('/admin');
revalidatePath('/');
}
/**
* Update global app title.
*/
export async function updateAppTitle(formData: FormData) {
if (!(await isAuthenticated())) throw new Error('Non autorisé');
const title = formData.get('title') as string;
if (!title) throw new Error('Titre requis.');
await prisma.config.upsert({
where: { id: 'app_title' },
update: { value: title },
create: { id: 'app_title', value: title },
});
revalidatePath('/admin');
revalidatePath('/');
}
+7
View File
@@ -6,6 +6,7 @@ import { LogOut, ArrowLeft, Trash2 } from 'lucide-react';
import Link from 'next/link';
import { AddButtonForm } from '@/components/AddButtonForm';
import { AdminButtonRow } from '@/components/AdminButtonRow';
import { EditTitleForm } from '@/components/EditTitleForm';
export const dynamic = 'force-dynamic';
@@ -17,6 +18,9 @@ export default async function AdminPage() {
orderBy: { order: 'asc' },
});
const titleConfig = await prisma.config.findUnique({ where: { id: 'app_title' } });
const appTitle = titleConfig?.value || 'Menu Application';
return (
<div style={{ minHeight: '100vh', padding: '1.5rem 2rem', maxWidth: '860px', margin: '0 auto' }}>
@@ -70,6 +74,9 @@ export default async function AdminPage() {
</div>
</header>
{/* Edit Title Form */}
<EditTitleForm currentTitle={appTitle} />
{/* Add form */}
<AddButtonForm />
+4 -1
View File
@@ -16,6 +16,9 @@ export default async function Home() {
orderBy: { order: 'asc' },
});
const titleConfig = await prisma.config.findUnique({ where: { id: 'app_title' } });
const appTitle = titleConfig?.value || 'Menu Application';
return (
<div style={{ minHeight: '100vh', display: 'flex', flexDirection: 'column' }}>
@@ -66,7 +69,7 @@ export default async function Home() {
letterSpacing: '-0.04em',
color: 'var(--fg)',
}}>
Menu Application
{appTitle}
</h1>
{buttons.length > 0 && (
<p style={{ color: 'var(--fg-muted)', fontSize: '0.9rem', marginTop: '0.4rem', fontWeight: 500 }}>