feat(orders): show a repeat-order pill when an order matches a delivery note
Blue Truck pill on the orders list, distinct from the amber quote suggestion and the teal linked quote. Reads potential_delivery_note_number (denormalized, no expand needed) — the service writes the relation and the number in the same update call so the list query doesn't pay for a second expanded relation (see orders-service.ts:253 for why the codebase avoids that). Additive — an order can show both a quote pill and a delivery-note pill at once; they're independent facts (a repeat-order observation, not a provenance link). Added potential_delivery_note: string and potential_delivery_note_number: string to the Order interface in src/lib/types.ts so the page gets the new fields via full-record return from getOrdersDashboardData (no fields: projection in the list path). Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
3df1c1874b
commit
370a270b4c
2 changed files with 36 additions and 0 deletions
|
|
@ -733,6 +733,28 @@ function OrderCard({
|
|||
Suggested
|
||||
</span>
|
||||
)}
|
||||
{/* Repeat-order pill — set by suggestDeliveryNoteForOrder
|
||||
when this order's items exactly match a past
|
||||
delivery note for the same company. Reads the
|
||||
denormalized number field (no `expand` needed, see
|
||||
orders-service.ts:253). Blue, distinct from the
|
||||
quote pills' amber/teal — a different kind of fact
|
||||
(a repeat-order observation, not a provenance link). */}
|
||||
{order.potential_delivery_note_number && (
|
||||
<span
|
||||
title={`Matches delivery note ${order.potential_delivery_note_number} — likely a repeat order`}
|
||||
className="inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium"
|
||||
style={{
|
||||
background: "rgba(59, 130, 246, 0.10)",
|
||||
color: "#3b82f6",
|
||||
boxShadow: "inset 0 0 0 1px rgba(59, 130, 246, 0.30)",
|
||||
}}
|
||||
aria-label={`Matches delivery note ${order.potential_delivery_note_number}`}
|
||||
>
|
||||
<Truck className="h-3 w-3" />
|
||||
{order.potential_delivery_note_number}
|
||||
</span>
|
||||
)}
|
||||
{complete && <CompleteBadge />}
|
||||
<span className="text-muted-foreground">·</span>
|
||||
<span className="truncate">
|
||||
|
|
|
|||
|
|
@ -655,6 +655,20 @@ export interface Order extends BaseRecord {
|
|||
quote_match_confidence: number;
|
||||
potential_quote: string;
|
||||
potential_quote_confidence: number;
|
||||
/**
|
||||
* Repeat-order detection — relation to a past delivery note whose
|
||||
* items exactly matched this order's. Set by
|
||||
* suggestDeliveryNoteForOrder at intake (see
|
||||
* order-delivery-note-link-service.ts). Visibility only — a wrong
|
||||
* flag costs nothing; the operator just ignores the pill.
|
||||
*/
|
||||
potential_delivery_note?: string;
|
||||
/** Denormalized copy of the matched DN's delivery_note_number.
|
||||
* Written alongside potential_delivery_note so the list pill can
|
||||
* render the number without a second `expand` (see
|
||||
* orders-service.ts:253). delivery_note_number is immutable once
|
||||
* assigned, so copying carries no staleness risk. */
|
||||
potential_delivery_note_number?: string;
|
||||
is_repair_order: boolean;
|
||||
/**
|
||||
* Sales rep handling this order. Free-text — auto-populated from the
|
||||
|
|
|
|||
Loading…
Reference in a new issue