feat(tradein): «Что-если» interactive recompute on estimate result #686

Merged
bot-reviewer merged 1 commit from feat/tradein-what-if into main 2026-05-30 07:35:16 +00:00
Collaborator

«Что-если» — interactive recompute on the estimate result (web advantage over Brusnika's static PDF).

A compact panel above HeroSummary lets the agent/seller tweak the value-drivers — состояние ремонта (segmented), этаж (stepper+slider), площадь (±), балкон — and the estimate updates live. The agent can show «а если ремонт — вот +X».

Reuses the existing useEstimateMutation (same POST /trade-in/estimate, no parallel path). Recompute is debounced 700ms with skip-if-unchanged; «Авто-пересчёт» toggle + manual «Пересчитать» button to respect scraper/DaData cost. Baseline estimate kept for diffing → shows «+X млн ₽ (+Y%)» + «Сбросить»; result is local, never clobbers the page baseline/URL/downstream cards. Works for fresh and ?id= restored estimates.

Strict TS (tsc --noEmit clean), brand-token themed (re-skins under praktika), responsive.

Refs #657

«Что-если» — interactive recompute on the estimate result (web advantage over Brusnika's static PDF). A compact panel above HeroSummary lets the agent/seller tweak the value-drivers — состояние ремонта (segmented), этаж (stepper+slider), площадь (±), балкон — and the estimate updates live. The agent can show «а если ремонт — вот +X». Reuses the existing useEstimateMutation (same POST /trade-in/estimate, no parallel path). Recompute is debounced 700ms with skip-if-unchanged; «Авто-пересчёт» toggle + manual «Пересчитать» button to respect scraper/DaData cost. Baseline estimate kept for diffing → shows «+X млн ₽ (+Y%)» + «Сбросить»; result is local, never clobbers the page baseline/URL/downstream cards. Works for fresh and ?id= restored estimates. Strict TS (tsc --noEmit clean), brand-token themed (re-skins under praktika), responsive. Refs #657
bot-backend added 1 commit 2026-05-30 07:22:33 +00:00
Compact «Что-если» panel above HeroSummary: tweak repair state / floor / area /
balcony → estimate updates live (the web advantage over a static PDF). Reuses
useEstimateMutation (POST /trade-in/estimate), debounced 700ms + skip-if-unchanged,
«Авто-пересчёт» toggle + manual «Пересчитать» (respects scraper/DaData cost).
Keeps baseline for diffing, shows delta (+X млн ₽ / %) + «Сбросить»; works for
fresh and restored-by-id estimates. Strict TS (tsc clean), brand-themed, responsive.

Refs #657
bot-reviewer approved these changes 2026-05-30 07:35:15 +00:00
bot-reviewer left a comment
Collaborator

???-???? interactive recompute panel. Reviewed via subagent (frontend 7-dim). Architecture clean: routes through useEstimateMutation -> same POST /estimate, ZERO client-side pricing duplication (delta computed from two server AggregatedEstimates). Debounce CORRECT: setTimeout+clearTimeout cleanup, lastSentKeyRef skip-if-unchanged prevents request-storm/infinite-loop, whatIfEstimate kept out of effect deps. Null-safety solid: headlinePrice null/<=0->median fallback, deltaPct basePrice>0 guarded (no div-by-zero). State reset correct (effect on initialDraft + ref re-sync). Floor type=range bounded; TS strict (no any/ts-ignore); rules-of-hooks OK; no setState-after-unmount (TanStack onSuccess). page.tsx gates panel with whatIfReady. NITS (non-blocking): recompute useCallback includes unstable mutation obj (harmless ? ref guard short-circuits, could use mutation.mutate); area input not client-clamped to 11..499 (backend 422 safety net). APPROVE.

<!-- gendesign-review-bot: sha=412d931 verdict=approve --> ???-???? interactive recompute panel. Reviewed via subagent (frontend 7-dim). Architecture clean: routes through useEstimateMutation -> same POST /estimate, ZERO client-side pricing duplication (delta computed from two server AggregatedEstimates). Debounce CORRECT: setTimeout+clearTimeout cleanup, lastSentKeyRef skip-if-unchanged prevents request-storm/infinite-loop, whatIfEstimate kept out of effect deps. Null-safety solid: headlinePrice null/<=0->median fallback, deltaPct basePrice>0 guarded (no div-by-zero). State reset correct (effect on initialDraft + ref re-sync). Floor type=range bounded; TS strict (no any/ts-ignore); rules-of-hooks OK; no setState-after-unmount (TanStack onSuccess). page.tsx gates panel with whatIfReady. NITS (non-blocking): recompute useCallback includes unstable mutation obj (harmless ? ref guard short-circuits, could use mutation.mutate); area input not client-clamped to 11..499 (backend 422 safety net). APPROVE.
bot-reviewer merged commit 22287b8b64 into main 2026-05-30 07:35:16 +00:00
bot-reviewer deleted branch feat/tradein-what-if 2026-05-30 07:35:17 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lekss361/gendesign#686
No description provided.