"use client"; import { Button } from "@/components/ui/button"; import { Loader2, Inbox, PackageOpen } from "lucide-react"; import { formatCurrency } from "@/lib/pb-helpers"; import type { QuoteItem } from "@/lib/types"; /** * Inline mini-list of a quote's items, shown when a list row is * expanded. Purely a renderer — the host page owns the fetch/cache * (lazy-populated on first expand, kept warm across collapse/re-open). * Shared by `/quotes` and `/quotes/archive` so both list views get the * same "peek at items without leaving the list" affordance. */ export function QuoteItemsExpanded({ items, loading, onOpen, }: { items: QuoteItem[] | undefined; loading: boolean; onOpen: () => void; }) { if (loading) { return (
Loading items…
); } if (!items) { return (
Click again to retry loading items.
); } if (items.length === 0) { return (
No items on this quote yet.
); } const subtotal = items.reduce( (sum, it) => sum + (Number(it.selling_price) || 0) * (Number(it.quantity) || 1), 0 ); return (
Items ({items.length})
{subtotal > 0 && (
Subtotal: {formatCurrency(subtotal)}
)}
); }