import { AbsenceEntry } from "@/lib/types";
import { Card, CardContent } from "../ui/card";

export function TeacherAbsenceItem({ entry }: { entry: AbsenceEntry }) {
  const getTeacherName = (e: AbsenceEntry) => {
      if (e.type === 'invalid') return null;
      return e.teacher;
  };

  const teacherName = getTeacherName(entry) || 'Neznámý';

  const getTypeDescription = (e: AbsenceEntry) => {
    switch (e.type) {
      case 'wholeDay': return 'Celý den';
      case 'single': return `${e.hours}. hodinu`;
      case 'range': return `${e.hours.from}-${e.hours.to} hodinu`;
      case 'exkurze': return 'Na exkurzi'; 
      case 'zastoupen': return `Zastoupen (${e.zastupuje.teacher || 'Neznámý'})`;
      case 'invalid': return `Neplatný záznam: ${e.original}`;
      default: return 'Neznámý';
    }
  };

  return (
    <Card>
      <CardContent>
        <div className="font-bold text-base text-slate-800 dark:text-slate-200">{teacherName}</div>
        <div className="text-sm text-slate-500 dark:text-slate-400">
          {getTypeDescription(entry)}
        </div>
      </CardContent>
    </Card>
  );
}
