import { prisma } from '@/lib/db'; import { isAuthenticated, logoutAdmin, deleteButton } from '@/app/actions/admin'; import { redirect } from 'next/navigation'; import { ThemeToggle } from '@/components/ThemeToggle'; import { LogOut, ArrowLeft, Trash2 } from 'lucide-react'; import Link from 'next/link'; import { AddButtonForm } from '@/components/AddButtonForm'; import { ICON_MAP, parseIcon } from '@/lib/lucideIcons'; import { Globe } from 'lucide-react'; export const dynamic = 'force-dynamic'; export default async function AdminPage() { const auth = await isAuthenticated(); if (!auth) redirect('/admin/login'); const buttons = await prisma.button.findMany({ orderBy: { order: 'asc' }, }); return (
{/* Header */}

Administration

{buttons.length} application{buttons.length !== 1 ? 's' : ''} configurée{buttons.length !== 1 ? 's' : ''}

{/* Add form */} {/* Button list */} {buttons.length === 0 ? (
Aucun bouton configuré.
) : (
{(buttons as any[]).map((btn) => { const { name: iconName, color } = parseIcon(btn.icon); const IconComponent = ICON_MAP[iconName] || Globe; return (
{btn.name}
{btn.url}
{ 'use server'; await deleteButton(btn.id); }}>
); })}
)}
); }