feat: add impact delta computation with TDD tests
Implements computeImpactDeltas pure function with 8 TDD tests covering replace/add/none modes and null weight/price handling. Adds useImpactDeltas hook, categoryId to ThreadWithCandidates, and selectedSetupId state to uiStore. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
22
src/client/hooks/useImpactDeltas.ts
Normal file
22
src/client/hooks/useImpactDeltas.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { useMemo } from "react";
|
||||
import {
|
||||
type CandidateDelta,
|
||||
type CandidateInput,
|
||||
computeImpactDeltas,
|
||||
type DeltaMode,
|
||||
type ImpactDeltas,
|
||||
type SetupItemInput,
|
||||
} from "../lib/impactDeltas";
|
||||
|
||||
export type { CandidateDelta, DeltaMode, ImpactDeltas };
|
||||
|
||||
export function useImpactDeltas(
|
||||
candidates: CandidateInput[],
|
||||
setupItems: SetupItemInput[] | undefined,
|
||||
threadCategoryId: number,
|
||||
): ImpactDeltas {
|
||||
return useMemo(
|
||||
() => computeImpactDeltas(candidates, setupItems, threadCategoryId),
|
||||
[candidates, setupItems, threadCategoryId],
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user