Collection
Hospitality / Revenue & Inventory · v0.2.1Validated
Inspect a dated room restriction and its channel synchronisation. Confirm a change when permitted.
Room Sales Holds · Preview
Loading widget…
Preparing source code…
Idle
Hospitality / Revenue & Inventory · v0.2.1Validated
Inspect a dated room restriction and its channel synchronisation. Confirm a change when permitted.
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 { StopSellWidget } from "@lumo/widgets/catalog/hotel-revenue/stop-sell";
export default function Example() {
return <StopSellWidget />;
}Props for integrating the React component in your app.
snapshotStopSellSnapshot | null (optional)onAction(action: StopSellAction) => void | Promise<void>{
"snapshot": {
"property": "Juniper House",
"roomType": "Courtyard Double",
"stayDate": "2026-12-18",
"revision": "r2",
"stopped": true,
"canEdit": true,
"channels": [
{
"id": "web",
"name": "City breaks",
"status": "failed",
"note": "Confirmation unavailable"
}
]
}
}"use client";
import { AnimatedNumber, Badge, Button, useScrollShadow, WidgetCard, WidgetDialog } from "@lumo/ui";
import { motionTokens } from "@lumo/tokens";
import { CalendarCheck, CalendarX, CircleHelp } from "lucide-react";
import { motion, useReducedMotion } from "motion/react";
import { useRef, useState } from "react";
import { useOperationSnapshot } from "../../shared/operation-snapshot";
import { useWidgetCommand } from "../../shared/use-widget-command";
import shared from "../../shared/operations-list.module.css";
import styles from "../../shared/status-panels.module.css";
import layout from "./stop-sell.module.css";
export interface StopSellChannel { id: string; name: string; status: "synced" | "pending" | "failed" | "unknown"; note?: string }
export interface StopSellSnapshot { property: string; roomType: string; stayDate: string; revision: string;
stopped: boolean | null; canEdit?: boolean; channels: readonly StopSellChannel[] }
export interface StopSellAction { type: "set-stop-sell"; stayDate: string; revision: string; stopped: boolean }
const example: StopSellSnapshot = { property: "Juniper House", roomType: "Courtyard Double", stayDate: "2026-12-18", revision: "rev-2",
stopped: true, canEdit: true, channels: [{ id: "direct", name: "Direct", status: "synced" },
{ id: "desk", name: "Travel desk", status: "pending" }, { id: "web", name: "City breaks", status: "failed", note: "Channel status not confirmed." }] };
const states = { synced: { label: "Synced", tone: "success" }, pending: { label: "Pending", tone: "warning" },
failed: { label: "Failed", tone: "danger" }, unknown: { label: "Unknown", tone: "neutral" } } as const;
const channelStates = ["synced", "pending", "failed", "unknown"] as const;
export function StopSellWidget({ snapshot, onAction }: { index?: number; snapshot?: StopSellSnapshot | null;
onAction?: (action: StopSellAction) => void | Promise<void> } = {}) {
const { data, action } = useOperationSnapshot<StopSellSnapshot, StopSellAction>(snapshot, example, onAction, (value, command) => ({ ...value,
stopped: command.stopped, revision: value.revision + "*", channels: value.channels.map(channel => ({ ...channel, status: "pending", note: undefined })) }));
const [open, setOpen] = useState(false);
const [confirm, setConfirm] = useState<string>();
const trigger = useRef<HTMLButtonElement>(null);
const scroll = useScrollShadow<HTMLUListElement>();
const reduced = useReducedMotion();
const request = useWidgetCommand(action);
const state = data?.stopped === true ? "Sales stopped" : data?.stopped === false ? "Open for sale" : "State unavailable";
const RestrictionIcon = data?.stopped === true ? CalendarX : data?.stopped === false ? CalendarCheck : CircleHelp;
const channels = data?.channels ?? [];
const counts = { synced: 0, pending: 0, failed: 0, unknown: 0 };
for (const channel of channels) counts[channel.status]++;
const canEdit = Boolean(action && data?.canEdit && data.revision && typeof data.stopped === "boolean");
const next = data?.stopped === false;
const requestLabel = next ? "Stop sales" : "Reopen sales";
const identity = data && `${data.property}:${data.roomType}:${data.stayDate}:${data.revision}:${data.stopped}`;
const close = () => { setOpen(false); setConfirm(undefined); request.reset(); };
async function submit() {
if (!canEdit || !data || identity !== confirm) return;
if (await request.run({ type: "set-stop-sell", stayDate: data.stayDate, revision: data.revision, stopped: next })) setConfirm(undefined);
}
const card = <WidgetCard title="Room Sales Holds" description={data?.roomType} icon={<CalendarX />} size="small"
className={`${shared.smallCard} ${shared.stableCard} ${layout.card}`}>
{data ? <div className={layout.overview}>
<div className={layout.restriction} data-state={data.stopped === true ? "held" : data.stopped === false ? "open" : undefined}>
<span className={layout.symbol}><RestrictionIcon size={16} aria-hidden="true" /></span>
<span className={layout.restrictionBody}><strong>{state}</strong><span className={shared.twoLines}>{data.stayDate} · {data.property}</span></span>
</div>
<motion.div className={layout.distribution} aria-hidden="true" initial={reduced ? false : { scaleX: 0 }} animate={{ scaleX: 1 }}
transition={reduced ? { duration: 0 } : motionTokens.spring.smooth}>
{channelStates.filter(status => counts[status] > 0).map(status => <span key={status} data-status={status} style={{ flexGrow: counts[status] }} />)}
</motion.div>
{channels.length ? <dl aria-label="Channel synchronisation" className={layout.stats}>
{channelStates.map(status => <div data-status={status} key={status}>
<dt>{states[status].label}</dt><dd><AnimatedNumber value={counts[status]} /></dd>
</div>)}
</dl> : <span className={shared.muted}>No channels reported</span>}
<Button className={layout.details} size="xs" type="button" variant="secondary" aria-haspopup="dialog" ref={trigger}
onClick={() => { request.reset(); setOpen(true); }}>Channels & restriction</Button>
</div> : <p className={shared.muted}>Restriction feed unavailable.</p>}
</WidgetCard>;
return <WidgetDialog surface={card} title="Channels & restriction" open={Boolean(data && open)} className={shared.smallCard}
returnFocusRef={trigger} placement="bottom" onClose={close}>
{data && <div className={shared.details}>
<p className={shared.muted}>{data.roomType} · {data.stayDate} · {data.property}</p>
{channels.length > 0 && <ul ref={scroll} data-widget-list tabIndex={0} aria-label="Channel synchronisation" className={`${styles.reportList} ${shared.compactScrollList}`}>
{channels.map(channel => <li key={channel.id} className={styles.readingRow}>
<span>{channel.name}{channel.note && <span className={shared.muted}><br />{channel.note}</span>}</span>
<Badge size="sm" tone={states[channel.status].tone}>{states[channel.status].label}</Badge>
</li>)}
</ul>}
{canEdit && (confirm && confirm === identity ? <>
<p>{requestLabel} for {data.roomType} on {data.stayDate}?</p>
<div className={styles.inline}><Button type="button" size="xs" variant="secondary" onClick={() => setConfirm(undefined)}>Back</Button>
<Button type="button" size="xs" disabled={request.status === "saving"} onClick={() => void submit()}>Confirm</Button></div>
</> : <Button type="button" size="xs" disabled={request.status === "saving" || request.status === "saved"}
onClick={() => setConfirm(identity ?? undefined)}>{requestLabel}</Button>)}
{request.status === "saved" && <p role="status">Request submitted. Channel status follows the feed.</p>}
{request.status === "error" && <p role="alert">Couldn’t submit. Try again.</p>}
</div>}
</WidgetDialog>;
}
lucide-reactmotionreactreact-dom