import { useTranslation } from "react-i18next"; import type { CandidateDelta } from "../hooks/useImpactDeltas"; interface ImpactDeltaBadgeProps { delta: CandidateDelta | undefined; type: "weight" | "price"; formatFn: (value: number) => string; } export function ImpactDeltaBadge({ delta, type, formatFn, }: ImpactDeltaBadgeProps) { const { t } = useTranslation("setups"); if (!delta || delta.mode === "none") return null; const value = type === "weight" ? delta.weightDelta : delta.priceDelta; if (value === null) { return ; } if (value === 0) { return ±0; } if (value > 0) { return ( +{formatFn(value)} {delta.mode === "add" && ( ({t("impact.adding")}) )} ); } // value < 0 return {formatFn(value)}; }