"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 (
{/*
* `items-start` (vs the default `items-center`) so the right
* price column anchors to the top of the row regardless of
* whether the description is one line, two lines, or more.
* Without this, a single-line "no price yet" placeholder
* floats in the vertical middle of mixed rows where other
* items have a 2-line price stack — feels orphaned.
*/}
{/* Long descriptions wrap inside the row width instead
of being clipped to one line. `whitespace-pre-wrap`
preserves the supplier's line breaks (POs sometimes
ship with multiline notes), `break-words` lets very
long unbroken tokens wrap at any character instead
of forcing horizontal scroll. */}
{it.description || "(no description)"}
Qty: {it.quantity || 1}
{it.expand?.supplier?.suppliername && (
Supplier: {it.expand.supplier.suppliername}
)}
{/*
* Pair with the "processed" branch above: green when the
* item is priced, warm amber when it isn't. We use `text-warn`
* (the amber itself), NOT `text-warn-foreground` — the
* foreground token is intentionally dark because it's
* designed to sit on a warn-tinted background (see the
* FollowUpChip). As a standalone span with no background
* it renders near-black on the dark canvas and disappears.
* `text-warn` keeps the same semantic pair (success ↔ warn)
* while reading on both light and dark themes.
*/}
{it.is_processed ? (
processed
) : (
not processed
)}