@metron-labs/quote-react 0.1.69 → 0.1.70

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,5 +17,6 @@ export declare function candidateFromCart(item: CartItem): MatchCandidate;
17
17
  export declare function refreshedCartItem(refreshed: CartItem, existing: CartItem): CartItem;
18
18
  export declare function displayLineLabel(item: LineItem, allItems: LineItem[]): string;
19
19
  export declare function formatResultsTotal(totalValue: number | null, needsPricingCount: number): string | null;
20
+ export declare function curatedCandidates(candidates: MatchCandidate[], result: MatchResult | undefined, selectedProductId: string | null): MatchCandidate[];
20
21
  export default function ScheduleResultsStage({ scheduleResult, onStartOver, cart, onAddToCart, onRemoveFromCart, onGoToBasket, cartSeeded, onCartSeeded, reviewGateComplete, onReviewGateComplete, internal, }: ResultsStageProps): import("react").JSX.Element;
21
22
  export {};
@@ -189,23 +189,14 @@ function LinkedGroupPill({ meta }) {
189
189
  }
190
190
  return (_jsx("span", { className: "results-linked-pill", style: meta.bubbleStyle, children: `Link ${meta.token}` }));
191
191
  }
192
- function curatedCandidates(candidates, result, selectedProductId) {
192
+ export function curatedCandidates(candidates, result, selectedProductId) {
193
193
  const recommendedIds = result?.rerank?.recommendedCandidateIds ?? [];
194
- if (recommendedIds.length === 0) {
195
- const topCandidates = candidates.slice(0, 6);
196
- const pinnedSelected = !topCandidates.some((candidate) => candidate.product_id === selectedProductId)
197
- ? candidates.find((candidate) => candidate.product_id === selectedProductId)
198
- : undefined;
199
- return pinnedSelected ? [...topCandidates, pinnedSelected] : topCandidates;
200
- }
201
194
  const byId = new Map(candidates.map((candidate) => [candidate.product_id, candidate]));
202
- const shown = recommendedIds.map((candidateId) => byId.get(candidateId)).filter((candidate) => candidate != null);
203
- if (selectedProductId && !shown.some((candidate) => candidate.product_id === selectedProductId)) {
204
- const selected = byId.get(selectedProductId);
205
- if (selected) {
206
- shown.unshift(selected);
207
- }
208
- }
195
+ const ordered = recommendedIds.length > 0
196
+ ? recommendedIds.map((candidateId) => byId.get(candidateId)).filter((candidate) => candidate != null)
197
+ : candidates.slice(0, 6);
198
+ const selected = selectedProductId ? byId.get(selectedProductId) : undefined;
199
+ const shown = selected ? [selected, ...ordered.filter(({ product_id }) => product_id !== selected.product_id)] : ordered;
209
200
  return [...new Map(shown.map((candidate) => [candidate.product_id, candidate])).values()].slice(0, 6);
210
201
  }
211
202
  function recommendedCandidates(result) {