import type { CSSProperties } from 'react'; import type { Task } from 'fhir/r4'; import { CheckboxControl } from '../ui/checkbox-control'; import { readChecklist, readChecklistTicks } from '../../utils/taskChecklist'; interface TaskChecklistProps { task: Task; /** Only the patient ticks a step; staff see the same list read-only. */ canTick: boolean; busy: boolean; onTick: (stepId: string) => void; } const tickedOn = (at: string): string => { const when = new Date(at); return Number.isNaN(when.getTime()) ? '' : when.toLocaleDateString(undefined, { day: 'numeric', month: 'short' }); }; export const TaskChecklist = ({ task, canTick, busy, onTick }: TaskChecklistProps) => { const steps = readChecklist(task); const ticks = new Map(readChecklistTicks(task).map((tick) => [tick.step, tick.at])); const done = steps.filter((step) => ticks.has(step.id)).length; if (steps.length === 0) return null; return (

Checklist

{done} of {steps.length} done
{canTick &&

Check off each item as you complete it.

}
); }; export default TaskChecklist;