import { redirect } from 'next/navigation';
import { getCurrentUser } from '@/lib/auth';
import { hasPageAccess } from '@/lib/permissions';
import DashboardLayout from '@/components/DashboardLayout';
import ConfigurationContent from '@/components/ConfigurationContent';

export default async function ConfigurationPage() {
  const user = await getCurrentUser();

  if (!user) {
    redirect('/login');
  }

  const hasAccess = await hasPageAccess(user.id, '/dashboard/parametres/configuration');
  if (!hasAccess) {
    redirect('/dashboard/parametres');
  }

  return (
    <DashboardLayout user={user}>
      <ConfigurationContent />
    </DashboardLayout>
  );
}
