import { CheckInCounterWidget, type TourCheckInAction } from "@lumo/widgets/catalog/tour-ops/check-in-counter";
type Manifest = {
id: string;
label: string;
guests: readonly { status: "due" | "arrived" | "no-show"; insured: boolean }[];
canRecordNoShows: boolean;
};
export function ManifestCounter({ manifest, update }: {
manifest: Manifest | null;
update: (action: TourCheckInAction) => Promise<void>;
}) {
const snapshot = manifest && {
departureId: manifest.id,
departure: manifest.label,
expected: manifest.guests.length,
arrived: manifest.guests.filter(guest => guest.status === "arrived").length,
noShows: manifest.guests.filter(guest => guest.status === "no-show").length,
uninsured: manifest.guests.filter(guest => !guest.insured).length,
allowedActions: manifest.canRecordNoShows ? ["arrival", "no-show"] as const : ["arrival"] as const,
};
return <CheckInCounterWidget snapshot={snapshot} onCheckInAction={update} />;
}