+ {error && (
+
+ Context lookup failed: {error}
+
+ )}
+
+ {data?.match.match_kind === "description_fuzzy" && (
+
+ ⚠ best-guess match · {Math.round(data.match.match_confidence * 100)}% confidence
+
+ )}
+
+ {data?.last_quote && (
+
|
}
+ badge={`${data.last_quote.quote_number} · ${relTime(data.last_quote.days_ago)}`}
+ cost={data.last_quote.cost_price}
+ selling={data.last_quote.selling_price}
+ markup={data.last_quote.markup_percent}
+ onApply={() => onApply({
+ source: "last_quote",
+ cost_price: round2(data.last_quote!.cost_price),
+ source_label: data.last_quote!.quote_number,
+ })}
+ />
+ )}
+
+ {data?.last_order && (
+
|
}
+ badge={`${data.last_order.order_number} · ${relTime(data.last_order.days_ago)}`}
+ cost={data.last_order.cost_price}
+ selling={data.last_order.selling_price}
+ markup={data.last_order.markup_percent}
+ onApply={() => onApply({
+ source: "last_order",
+ cost_price: round2(data.last_order!.cost_price),
+ source_label: data.last_order!.order_number,
+ })}
+ />
+ )}
+
+ {data?.last_invoiced && (
+
|
}
+ badge={`${data.last_invoiced.supplier_invoice_number} · ${relTime(data.last_invoiced.days_ago)}`}
+ cost={data.last_invoiced.cost_price}
+ selling={null}
+ markup={null}
+ sellingDimmed
+ onApply={() => onApply({
+ source: "last_invoiced",
+ cost_price: round2(data.last_invoiced!.cost_price),
+ source_label: data.last_invoiced!.supplier_invoice_number,
+ })}
+ />
+ )}
+
+ {data?.stock && (
+
|
}
+ badge={`${data.stock.current_qty} units (${data.stock.status.replace("_", " ")})`}
+ cost={data.stock.selling_price ?? 0}
+ selling={data.stock.selling_price ?? null}
+ markup={data.stock.markup_percent ?? null}
+ applyDisabled={data.stock.selling_price == null}
+ onApply={data.stock.selling_price != null ? () => onApply({
+ source: "stock",
+ cost_price: round2(data.stock!.selling_price!),
+ source_label: data.stock!.name,
+ }) : undefined}
+ />
+ )}
+
+ {noData && !loading && !error && (
+
+
No context for this item yet
+
First time we’re seeing this SKU — pick a supplier, set cost, save.
+
+ )}
+
+ )}
+