diff --git a/inertia/pages/widgets/NewPartSearch.vue b/inertia/pages/widgets/NewPartSearch.vue index 3581aa3..770ae37 100644 --- a/inertia/pages/widgets/NewPartSearch.vue +++ b/inertia/pages/widgets/NewPartSearch.vue @@ -64,6 +64,19 @@ async function comparePrices(part: ScrapedPart) { offers[part.id] = data.offers ?? [] if (offers[part.id].length === 0) { compareErrors[part.id] = true + return + } + + // The backend already persists the cheapest offer found as this + // part's new best-known price when it beats the catalog price (see + // ScrapedPartsController#compare / updatePriceIfCheaper). Mirror that + // here on the locally held result so the displayed catalog price + // (e.g. "€979.95") reflects it immediately, instead of staying stuck + // at whatever price the initial search returned until the user + // re-runs the search from scratch. + const cheapest = offers[part.id][0] + if (part.price === null || cheapest.price < part.price) { + part.price = cheapest.price } } catch { compareErrors[part.id] = true