2026-01-20 17:20:13 +01:00
|
|
|
import { redirect } from 'next/navigation';
|
|
|
|
|
import { getCurrentUser } from '@/lib/auth';
|
2026-01-22 18:53:23 +01:00
|
|
|
import { hasPageAccess } from '@/lib/permissions';
|
2026-01-20 17:20:13 +01:00
|
|
|
import DashboardLayout from '@/components/DashboardLayout';
|
2026-01-22 18:53:23 +01:00
|
|
|
import DashboardContent from '@/components/DashboardContent';
|
2026-01-20 17:20:13 +01:00
|
|
|
|
|
|
|
|
export default async function DashboardPage() {
|
|
|
|
|
const user = await getCurrentUser();
|
|
|
|
|
|
|
|
|
|
if (!user) {
|
|
|
|
|
redirect('/login');
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-22 18:53:23 +01:00
|
|
|
// Vérifier les permissions
|
|
|
|
|
const hasAccess = await hasPageAccess(user.id, '/dashboard');
|
|
|
|
|
if (!hasAccess) {
|
|
|
|
|
redirect('/dashboard/parametres'); // Rediriger vers une page accessible ou afficher une erreur
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-20 17:20:13 +01:00
|
|
|
return (
|
|
|
|
|
<DashboardLayout user={user}>
|
2026-01-22 18:53:23 +01:00
|
|
|
<DashboardContent userName={user.name} />
|
2026-01-20 17:20:13 +01:00
|
|
|
</DashboardLayout>
|
|
|
|
|
);
|
|
|
|
|
}
|