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

export default async function ParticipationFinancierePage() {
  const user = await getCurrentUser();
  if (!user) {
    redirect('/login');
  }

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

  return (
    <DashboardLayout user={user}>
      <div className="p-3 sm:p-4 md:p-6 lg:p-8">
        <h1 className="text-xl sm:text-2xl md:text-3xl font-semibold text-cblack mb-1 sm:mb-2">
          Participation financière
        </h1>
        <p className="text-xs md:text-sm text-cgray mb-4 sm:mb-6 md:mb-8">
          Documents de participation générés à la fin de chaque trajet
        </p>
        <ParticipationFinanciereList />
      </div>
    </DashboardLayout>
  );
}
