diff --git a/src/components/price-check-marker.tsx b/src/components/price-check-marker.tsx index 8ae46bf..f79b573 100644 --- a/src/components/price-check-marker.tsx +++ b/src/components/price-check-marker.tsx @@ -24,7 +24,7 @@ * the line afterwards. */ -import { useCallback, useState } from "react"; +import { useCallback, useEffect, useState } from "react"; import { Loader2, RefreshCw, Tags } from "lucide-react"; import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; @@ -117,6 +117,14 @@ export function PriceCheckMarker({ const [refreshing, setRefreshing] = useState(false); const [error, setError] = useState(null); + // The line's stored intel can change under us (the assistant fills + // the line, the operator saves it). Keep the badge in step with it. + useEffect(() => { + const next = asIntel(intel); + // eslint-disable-next-line react-hooks/set-state-in-effect -- mirror the line's stored intel into local state + if (next) setData(next); + }, [intel]); + const check = buildPriceCheck(data, { cost_price, selling_price,