
import { getServerSession } from 'next-auth';
import { redirect } from 'next/navigation';
import { authOptions } from '@/lib/auth';
import { DashboardCoordinador } from '@/components/dashboards/dashboard-coordinador';
import { DashboardProfesor } from '@/components/dashboards/dashboard-profesor';
import { DashboardAlumno } from '@/components/dashboards/dashboard-alumno';

export default async function DashboardPage() {
  const session = await getServerSession(authOptions);

  if (!session) {
    redirect('/auth/signin');
  }

  const { rol } = session.user;

  return (
    <div className="min-h-screen bg-gray-50">
      {rol === 'COORDINADOR' && <DashboardCoordinador user={session.user} />}
      {rol === 'PROFESOR' && <DashboardProfesor user={session.user} />}
      {(rol === 'ALUMNO' || rol === 'NO_PROFESOR') && <DashboardAlumno user={session.user} />}
    </div>
  );
}
