Collection
Hospitality / Housekeeping & Guests · v0.2.1Validated
Track repairs and return estimates, and review rooms that can go back into service.
Rooms Under Repair · Preview
Loading widget…
Preparing source code…
Idle
Hospitality / Housekeeping & Guests · v0.2.1Validated
Track repairs and return estimates, and review rooms that can go back into service.
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 { OutOfOrderWidget } from "@lumo/widgets/catalog/hotel-house/out-of-order";
export default function Example() {
return <OutOfOrderWidget />;
}Props for integrating the React component in your app.
snapshotOutOfOrderSnapshot | null (optional)onAction(action: OutOfOrderAction) => void | Promise<void>{
"snapshot": {
"property": "Maison Ardoise",
"currency": "EUR",
"rooms": [
{
"id": "M-341",
"room": "208",
"reason": "Radiator valve replaced",
"technician": "Eva Patel",
"lostRateMinor": 17500,
"state": "ready",
"releasable": true
}
]
}
}"use client";
import { AnimatedNumber, Badge } from "@lumo/ui";
import { ChevronRight, Clock3, Wrench } from "lucide-react";
import { operationMoney, useOperationSnapshot } from "../../shared/operation-snapshot";
import { WidgetOperations, type OperationRow } from "../../shared/WidgetOperations";
import { roomRepairDemo } from "./out-of-order.constants";
import type { OutOfOrderSnapshot, OutOfOrderAction } from "./out-of-order.types";
import styles from "../../shared/hotel-queue.module.css";
export type { OutOfOrderSnapshot, OutOfOrderAction, RoomRepair } from "./out-of-order.types";
export function OutOfOrderWidget({ snapshot, onAction }: {
index?: number; snapshot?: OutOfOrderSnapshot | null;
onAction?: (action: OutOfOrderAction) => void | Promise<void>;
} = {}) {
const { data, action } = useOperationSnapshot(snapshot, roomRepairDemo, onAction, (state, request) => ({
...state, rooms: state.rooms.filter(room => room.id !== request.repairId),
}));
const money = operationMoney(data?.currency ?? "EUR");
const rooms = data?.rooms.slice().sort((a, b) => Number(b.state === "ready") - Number(a.state === "ready"));
const rows = rooms?.map<OperationRow<OutOfOrderAction>>(room => {
const status = room.state === "ready" ? { label: "Ready to check", tone: "success" } as const : room.state === "repairing"
? { label: "In repair", tone: "warning" } as const : { label: "Queued", tone: "neutral" } as const;
return {
id: room.id, label: `Room ${room.room}`, caption: room.reason,
detailCaptionIcon: <Wrench size={14} aria-hidden="true" />,
status,
accessibleName: [`Room ${room.room}`, status.label, room.reason, room.returnEtaLabel].filter(Boolean).join(", "),
rowContent: <span className={styles.item}>
<span className={styles.itemLine}><Badge size="sm" tone={status.tone}>{status.label}</Badge><ChevronRight size={14} aria-hidden="true" /></span>
<strong className={styles.title}>Room {room.room}</strong>
<span className={styles.caption}>{room.reason}</span>
<span className={styles.captionLine}><Clock3 size={13} aria-hidden="true" /><span className={styles.caption}>{room.returnEtaLabel ?? "No return estimate"}</span></span>
</span>,
details: [["Ticket", room.id], ["Technician", room.technician ?? "Unassigned"], ["Return estimate", room.returnEtaLabel ?? "Not reported"],
["Nightly rate at risk", money(room.lostRateMinor)]],
actions: room.state === "ready" && room.releasable ? [{ label: "Return to service", command: { type: "return-to-service", repairId: room.id },
confirmation: `Return room ${room.room} to sellable inventory?` }] : [],
};
}) ?? null;
return <WidgetOperations title="Rooms Under Repair" description={data?.property} icon={<Wrench />} size="small" rows={rows}
stabilize fillPages className={styles.card} onAction={action} empty="All rooms available" summary={rooms && <dl className={styles.totals}>
<div><dt>Queued</dt><dd><AnimatedNumber value={rooms.filter(room => room.state === "open").length} /></dd></div>
<div data-tone="warning"><dt>In repair</dt><dd><AnimatedNumber value={rooms.filter(room => room.state === "repairing").length} /></dd></div>
<div data-tone="success"><dt>Ready</dt><dd><AnimatedNumber value={rooms.filter(room => room.state === "ready").length} /></dd></div>
</dl>} />;
}
lucide-reactmotionreactreact-dom