import { WaitingChatsWidget, type WaitingChatChannel, type WaitingChatClaim, type WaitingChatsSnapshot } from "@lumo/widgets/catalog/tour-guest/waiting-chats";
type InboxRow = {
key: string; guestName: string; transport: string; unassignedSinceMs: number;
summary?: string; portrait?: string; agentId?: string | null;
};
const channels = new Map<string, WaitingChatChannel>([
["mobile_whatsapp", "whatsapp"], ["social_dm", "instagram"], ["web", "chat"], ["mail", "email"],
]);
export function GuestInbox({ rows, claim }: {
rows: readonly InboxRow[] | null;
claim?: (request: WaitingChatClaim) => Promise<void>;
}) {
const snapshot: WaitingChatsSnapshot | null = rows === null ? null : {
inbox: "Harbour excursions",
chats: rows.filter(row => row.agentId == null).map(row => ({
id: row.key, name: row.guestName, channel: channels.get(row.transport) ?? "other",
receivedAt: row.unassignedSinceMs, subject: row.summary, avatarSrc: row.portrait,
})),
};
return <WaitingChatsWidget snapshot={snapshot} onClaim={claim} />;
}