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

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

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

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

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