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

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

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

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

  return (
    <DashboardLayout user={user}>
      <div className="p-4 sm:p-6 lg:p-8">
        <CalendrierPageContent />
      </div>
    </DashboardLayout>
  );
}
