"use client"; import Link from "next/link"; import { useMemo, useTransition } from "react"; import { AbsenceReason } from "@prisma/client"; import { Baby, CalendarX2, Check, ChevronRight, Loader2 } from "lucide-react"; import { reasonColor, reasonLabel } from "@/lib/absence-utils"; import { toast } from "sonner"; import { reportAbsence } from "@/actions/absences"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select"; import { Textarea } from "@/components/ui/textarea"; type ChildOption = { id: string; name: string; }; type AbsenceListItem = { id: string; childName: string; reason: AbsenceReason; note: string | null; startDate: string; endDate: string; }; export function AbsenceCard({ childOptions, today, }: { childOptions: ChildOption[]; absences: AbsenceListItem[]; today: string; }) { const [isPending, startTransition] = useTransition(); const defaultChildId = childOptions[0]?.id; const hasChildren = childOptions.length > 0; function handleSubmit(formData: FormData) { startTransition(async () => { const result = await reportAbsence({ childId: String(formData.get("childId") ?? ""), startDate: String(formData.get("startDate") ?? ""), endDate: String(formData.get("endDate") ?? ""), reason: String(formData.get("reason") ?? ""), note: String(formData.get("note") ?? ""), }); if (result.error) { toast.error(result.error); return; } toast.success("Abwesenheit gemeldet. Die Kita ist informiert."); }); } return (
Kind abmelden Melde dein Kind für ganze Tage ab. Die Kita sieht die Meldung sofort in der Tagesübersicht — keine zusätzliche E-Mail nötig.
{hasChildren ? (