rohitsar567 Claude Opus 4.7 (1M context) commited on
Commit
dab7341
·
1 Parent(s): dea6883

fix(types): KI-270 — Frontend UserProfile schema add 3 missing slots

Browse files

Closes the typing gap D1 flagged after KI-269: backend added
desired_sum_insured_inr (B5), copay_pct (D2), family_medical_history (D2)
to the Profile dataclass, but the frontend TS type was lagging.

frontend/src/lib/api.ts:
- UserProfile.desired_sum_insured_inr?: number (B5/KI-258)
- UserProfile.copay_pct?: number (D2/KI-269)
- UserProfile.family_medical_history?: string[](D2/KI-269)

frontend/src/app/page.tsx::PremiumCalculatorPanel:
- SI prefill now prefers desired_sum_insured_inr (the canonical target)
over existing_cover_inr (D1's typed-proxy fallback), with 1_000_000
ultimate fallback. Closes the typed-proxy workaround.

Verification:
- npx tsc --noEmit: clean
- npx next build: Compiled successfully, 4/4 static pages generated
- desired_sum_insured_inr now referenced in both api.ts type + page.tsx prefill

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

frontend/src/app/page.tsx CHANGED
@@ -2145,10 +2145,14 @@ function PremiumCalculatorPanel({
2145
  };
2146
 
2147
  const [age, setAge] = useState<number>(initialProfile?.age ?? 35);
 
 
 
 
2148
  const [sumInsured, setSumInsured] = useState<number>(
2149
- initialProfile?.existing_cover_inr && initialProfile.existing_cover_inr > 0
2150
- ? initialProfile.existing_cover_inr
2151
- : 1000000,
2152
  );
2153
  const [cityTier, setCityTier] = useState<"metro" | "tier1" | "tier2">(
2154
  deriveCityTier(initialProfile?.location_tier),
 
2145
  };
2146
 
2147
  const [age, setAge] = useState<number>(initialProfile?.age ?? 35);
2148
+ // KI-258 (B5, 2026-05-15) — Prefer `desired_sum_insured_inr` (the user's
2149
+ // stated target SI from chat/extractor) over `existing_cover_inr` (what
2150
+ // they already hold). Fall back to legacy 10L default when both are
2151
+ // missing.
2152
  const [sumInsured, setSumInsured] = useState<number>(
2153
+ initialProfile?.desired_sum_insured_inr ??
2154
+ initialProfile?.existing_cover_inr ??
2155
+ 1_000_000,
2156
  );
2157
  const [cityTier, setCityTier] = useState<"metro" | "tier1" | "tier2">(
2158
  deriveCityTier(initialProfile?.location_tier),
frontend/src/lib/api.ts CHANGED
@@ -424,6 +424,14 @@ export type UserProfile = {
424
  parents_has_ped?: boolean | null;
425
  health_conditions?: string[] | null;
426
  budget_band?: string | null;
 
 
 
 
 
 
 
 
427
  };
428
 
429
  export type ProfileCompletenessResponse = {
 
424
  parents_has_ped?: boolean | null;
425
  health_conditions?: string[] | null;
426
  budget_band?: string | null;
427
+ // KI-258 (B5, 2026-05-15) — Desired sum insured slot. Backend's pricing
428
+ // endpoint + retrieve_policies query both read this; frontend pre-fills
429
+ // the PremiumCalculatorPanel SI slider from it when present.
430
+ desired_sum_insured_inr?: number;
431
+ // KI-269 (D2, 2026-05-15) — Co-pay % the user is willing to accept.
432
+ copay_pct?: number;
433
+ // KI-269 (D2, 2026-05-15) — Family medical history (free-text tags).
434
+ family_medical_history?: string[];
435
  };
436
 
437
  export type ProfileCompletenessResponse = {