Skip to content

Fix insurance category enum mismatch between AddPolicyModal and Zod schema #189

@jcleow

Description

@jcleow

Problem

The AddPolicyModal's PolicyCategory type and the Zod insuranceCategoryEnum in types/insurance.ts define completely different category value sets. This causes filter mismatches and potential data inconsistency.

AddPolicyModal (PolicyCategory)

life | health | critical_illness | long_term_care | personal_accident

Zod Schema (insuranceCategoryEnum)

life | critical_illness | hospitalization | disability | accident | custom

Mismatches

Concept Modal saves Zod expects
Health/Hospital health hospitalization
Disability/LTC long_term_care disability
Personal Accident personal_accident accident
Custom (not offered) custom

Impact

  • Coverage column filter in PoliciesTab was sending Zod enum values (hospitalization, accident) to the backend, but the DB contains modal values (health, personal_accident) — filter returned no results
  • long_term_care is defined as a subcategory of disability in the Zod schema, but stored as a top-level category by the modal
  • JourneyTab uses yet another set of category keys (lifeTpd, criticalIllness, earlyCi, disability, personalAccident)

Fix needed

  1. Decide on a single canonical set of category values
  2. Align AddPolicyModal's PolicyCategory type with insuranceCategoryEnum
  3. Write a DB migration if existing data needs to be remapped
  4. Update insuranceSubcategories mapping accordingly
  5. Ensure JourneyTab's category keys map correctly to the canonical values

Files involved

  • frontend/src/types/insurance.ts — Zod enum + subcategory map
  • frontend/src/components/insurance/modals/AddPolicyModal.tsxPolicyCategory type
  • frontend/src/components/insurance/tabs/PoliciesTab.tsxCOVERAGE_CATEGORIES filter
  • frontend/src/components/insurance/tabs/JourneyTab.tsxIndividualCategory type
  • Backend handler/repository for any migration

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High priorityinsuranceInsurance module relatedtech-debtTechnical debt or cleanup

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions