Collection
Hospitality / Front Desk & Rack · v0.2.0Validated
Review room holds by expiration and confirm or release an eligible stay.
Reservation Holds · Preview
Loading widget…
Preparing source code…
Idle
Hospitality / Front Desk & Rack · v0.2.0Validated
Review room holds by expiration and confirm or release an eligible stay.
Loading widget…
Preparing source code…
Load the Lumo theme once in your app entry point. The example uses the local Lumo workspace packages.
import "@lumo/tokens/tokens.css";
import { OptionHoldsWidget } from "@lumo/widgets/catalog/hotel-desk/option-holds";
export default function Example() {
return <OptionHoldsWidget />;
}Props for integrating the React component in your app.
snapshotOptionHoldsSnapshot | null (optional)onAction(action: OptionHoldsAction) => void | Promise<void>{
"snapshot": {
"property": "Maison Ardoise",
"asOf": 1795616400000,
"holds": [
{
"id": "OH-14",
"guest": "Jules Laurent",
"stayLabel": "7–9 Dec",
"rooms": 1,
"roomLabel": "Courtyard King",
"expiresAt": 1795625400000
}
]
}
}"use client";
import { CalendarClock } from "lucide-react";
import { nonnegativeInteger, relativeWindow, useOperationSnapshot, validTimestamp } from "../../shared/operation-snapshot";
import { WidgetOperations, type OperationRow } from "../../shared/WidgetOperations";
import { holdDemo } from "./option-holds.constants";
import type { OptionHoldsSnapshot, OptionHoldsAction } from "./option-holds.types";
export type { OptionHoldsSnapshot, OptionHoldsAction, RoomHold } from "./option-holds.types";
export function OptionHoldsWidget({ snapshot, onAction }: {
index?: number; snapshot?: OptionHoldsSnapshot | null;
onAction?: (action: OptionHoldsAction) => void | Promise<void>;
} = {}) {
const { data, action } = useOperationSnapshot(snapshot, holdDemo, onAction, (state, request) => ({
...state, holds: state.holds.filter(hold => hold.id !== request.holdId),
}));
const rank = (time: number) => validTimestamp(time) ? time : Infinity;
const rows = data ? data.holds.slice().sort((a, b) => rank(a.expiresAt) - rank(b.expiresAt)).map<OperationRow<OptionHoldsAction>>(hold => {
const valid = validTimestamp(hold.expiresAt) && validTimestamp(data.asOf);
const expired = valid && hold.expiresAt <= data.asOf;
return {
id: hold.id, label: hold.guest, caption: hold.stayLabel, value: relativeWindow(hold.expiresAt, data.asOf),
status: expired ? { label: "Expired", tone: "danger" } : valid && hold.expiresAt - data.asOf < 21_600_000
? { label: "Due soon", tone: "warning" } : undefined,
details: [["Hold", hold.id], ["Room type", hold.roomLabel ?? "Unassigned"], ["Rooms", nonnegativeInteger(hold.rooms) ? String(hold.rooms) : "Unavailable"]],
actions: [
...(valid && !expired ? [{ label: "Confirm booking", command: { type: "confirm", holdId: hold.id },
confirmation: "Confirm this held stay as a reservation?" }] as const : []),
{ label: "Release hold", command: { type: "release", holdId: hold.id }, confirmation: "Release the held rooms back to inventory?" },
],
};
}) : null;
return <WidgetOperations title="Option Holds" description={data?.property} icon={<CalendarClock />} size="small" rows={rows}
onAction={action} empty="No room holds" summary={rows && <><strong>{rows.length}</strong><span>holds to review</span></>} />;
}
lucide-reactmotionreactreact-dom