From fa74791c92ab92c944bdcf51d437cf0d456d5a58 Mon Sep 17 00:00:00 2001 From: Kevin L'Hereec Date: Thu, 23 Jul 2026 17:01:08 +0200 Subject: [PATCH] fix: update displayed catalog price after comparing merchant prices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The catalog price shown next to a part (e.g. '€979.95') stayed stuck at its initial search-result value even after 'Compare prices' found and persisted a cheaper offer server-side (updatePriceIfCheaper already saves it to the database, but the locally held search result was never updated) — so the UI showed a stale, higher price right above a correctly-labeled 'cheapest' offer, which was confusing (e.g. '€979.95' next to 'Cdiscount: €741.51 (cheapest)'). comparePrices() now also updates part.price locally when the cheapest offer found beats it (or no catalog price was known), mirroring what the backend already persisted, so the display is consistent without needing to re-run the search. --- inertia/pages/widgets/NewPartSearch.vue | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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