import { useState } from 'react' import { Link } from '@tanstack/react-router' import type { AbsenceReasonValue } from '@gruperly/shared' import { ArrowLeft, Loader2 } from 'lucide-react' import { Button, Label } from '../../components/ui' import { cn } from '../../lib/utils' import { FlowDone } from './FlowDone' import { FlowFooter } from './FlowFooter' import { ABSENCE_REASON_LABELS, firstName, formatShortDate, formatTime } from './format' import { SelectableRow } from './SelectableRow' import { useStudentApp } from './StudentAppProvider' const REASONS = Object.keys(ABSENCE_REASON_LABELS) as AbsenceReasonValue[] export function NotifyAbsenceView({ preselected }: { preselected?: string }) { const { student, classes, notifyAbsences } = useStudentApp() const [selected, setSelected] = useState(preselected ? [preselected] : []) const [reason, setReason] = useState(null) const [message, setMessage] = useState('') if (!student || !classes) { return (
) } const teacher = firstName(student.teacherName) if (notifyAbsences.isSuccess) { return (

Si cambiás de idea, podés deshacerlo desde Clases mientras la clase no haya empezado.

Volver al inicio Ver mis clases
) } // Classes not started and not notified yet. const available = classes.classes.filter((item) => !item.started && !item.notice) const toggle = (startsAt: string) => setSelected((current) => (current.includes(startsAt) ? current.filter((value) => value !== startsAt) : [...current, startsAt])) const count = selected.filter((value) => available.some((item) => item.startsAt === value)).length const submit = () => { if (count === 0) return notifyAbsences.mutate({ startsAt: selected.filter((value) => available.some((item) => item.startsAt === value)), reason, message: message.trim() || null, }) } return (