44 lines
1.5 KiB
TypeScript
44 lines
1.5 KiB
TypeScript
import { CheckCircle2, Loader2 } from 'lucide-react'
|
|
import { Button } from '../../components/ui'
|
|
import { useAbsenceNotify } from './AbsenceNotifyProvider'
|
|
|
|
type AbsenceSession = {
|
|
sessionId: string
|
|
startsAt: string
|
|
groupName: string
|
|
notified: boolean
|
|
}
|
|
|
|
export function AbsenceSessionRow({ session }: { session: AbsenceSession }) {
|
|
const { isNotified, isNotifying, notify } = useAbsenceNotify()
|
|
const time = new Date(session.startsAt).toLocaleTimeString('es-MX', {
|
|
hour: '2-digit',
|
|
minute: '2-digit',
|
|
hour12: false,
|
|
})
|
|
|
|
return (
|
|
<li className="flex items-center justify-between gap-3 rounded-xl border border-border bg-primary-soft/30 px-4 py-3">
|
|
<div className="min-w-0">
|
|
<p className="text-sm font-semibold text-primary">Hoy · {time} hs</p>
|
|
<p className="truncate text-xs text-foreground/60">{session.groupName}</p>
|
|
</div>
|
|
{isNotified(session) ? (
|
|
<span className="inline-flex shrink-0 items-center gap-1.5 rounded-full bg-success-soft px-2.5 py-1 text-xs font-medium text-success">
|
|
<CheckCircle2 className="size-3.5" />
|
|
Ya avisaste
|
|
</span>
|
|
) : (
|
|
<Button
|
|
variant="primary"
|
|
size="sm"
|
|
disabled={isNotifying(session.sessionId)}
|
|
onClick={() => notify(session.sessionId)}
|
|
>
|
|
{isNotifying(session.sessionId) ? <Loader2 className="size-4 animate-spin" /> : null}
|
|
Avisar ausencia
|
|
</Button>
|
|
)}
|
|
</li>
|
|
)
|
|
} |