Collection
Tour Operator / Tour Bookings · v0.2.0Validated
See which custom travel offers have been viewed, accepted or need a follow-up.
Travel Offer Follow-Ups · Preview
Loading widget…
Preparing source code…
Idle
Tour Operator / Tour Bookings · v0.2.0Validated
See which custom travel offers have been viewed, accepted or need a follow-up.
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 { OffersPulseWidget } from "@lumo/widgets/catalog/tour-sales/offers-pulse";
export default function Example() {
return <OffersPulseWidget />;
}Props for integrating the React component in your app.
snapshotOfferActivitySnapshot | null (optional)onAction(action: OfferActivityAction) => void | Promise<void>{
"snapshot": {
"period": "Today",
"currency": "EUR",
"offers": [
{
"id": "OF-315",
"customer": "Lucía Moreno",
"trip": "Madeira walking weekend",
"amountMinor": 186000,
"status": "sent",
"views": 4,
"lastViewedLabel": "10:18 WET"
}
]
}
}"use client";
import { Send } from "lucide-react";
import { operationMoney, useOperationSnapshot, nonnegativeInteger } from "../../shared/operation-snapshot";
import { WidgetOperations, type OperationRow } from "../../shared/WidgetOperations";
import { offerActivityDemo } from "./offers-pulse.constants";
import type { OfferActivitySnapshot, OfferActivityAction } from "./offers-pulse.types";
export type { OfferActivitySnapshot, OfferActivityAction, SalesOffer } from "./offers-pulse.types";
export function OffersPulseWidget({ snapshot, onAction }: {
index?: number; snapshot?: OfferActivitySnapshot | null;
onAction?: (action: OfferActivityAction) => void | Promise<void>;
} = {}) {
const { data, action } = useOperationSnapshot(snapshot, offerActivityDemo, onAction, (state, command) => ({
...state, offers: state.offers.map(offer => offer.id === command.id ? { ...offer, followUpSent: true } : offer),
}));
const money = operationMoney(data?.currency ?? "EUR");
const viewed = data?.offers.filter(offer => offer.status === "sent" && nonnegativeInteger(offer.views) && offer.views > 0 && !offer.followUpSent).length ?? 0;
const rows = data?.offers.map<OperationRow<OfferActivityAction>>(offer => ({
id: offer.id, label: offer.customer, caption: offer.trip, value: money(offer.amountMinor),
status: offer.status === "accepted" ? { label: "Accepted", tone: "success" } : offer.status === "declined"
? { label: "Declined", tone: "neutral" } : offer.followUpSent ? { label: "Followed up", tone: "info" }
: nonnegativeInteger(offer.views) && offer.views > 0 ? { label: "Viewed", tone: "info" } : { label: "Sent", tone: "neutral" },
details: [["Offer", offer.id], ["Link views", nonnegativeInteger(offer.views) ? String(offer.views) : "Unavailable"],
["Last viewed", offer.lastViewedLabel ?? "Unavailable"]],
actions: offer.status === "sent" && !offer.followUpSent ? [{ label: "Send follow-up", command: { type: "follow-up", id: offer.id } }] : [],
})) ?? null;
return <WidgetOperations title="Offer Activity" description={data?.period} icon={<Send />} rows={rows} onAction={action}
empty="No offers in this period" summary={data && <><strong>{viewed}</strong><span>viewed · awaiting follow-up</span></>} />;
}
lucide-reactmotionreactreact-dom