2.6 KiB
2.6 KiB
Hotfix 1: Customer Sub Group
1. Files Added
drizzle/0011_brief_hobgoblin.sqldocs/implementation/hotfix-1-customer-sub-group.md
2. Files Modified
src/db/schema.tssrc/db/seeds/foundation.seed.tssrc/features/crm/customers/api/types.tssrc/features/crm/customers/schemas/customer.schema.tssrc/features/crm/customers/server/service.tssrc/app/api/crm/customers/route.tssrc/app/api/crm/customers/[id]/route.tssrc/components/forms/fields/select-field.tsxsrc/features/crm/customers/components/customer-form-sheet.tsxsrc/features/crm/customers/components/customer-columns.tsxsrc/features/crm/customers/components/customer-detail.tsx
3. Schema Field Used/Added
- Added optional field
customerSubGrouptocrm_customers - Field is stored with the same option-id pattern already used by
customerGroup
4. Master Options Seeded
crm_customer_groupindustrialconstructiongovernmentdealerother
crm_customer_sub_groupfactorywarehouselogisticscontractorconsultantstate_enterprisegovernment_agencyresellerother
Child options resolve and store parentId from the seeded crm_customer_group rows during idempotent seed execution.
5. Form Behavior Added
- Add/Edit Customer now includes
Customer Sub Group - Sub group is disabled until a customer group is selected
- Edit mode loads the saved group and sub group
- Submit payload now persists
customerSubGroup
6. Parent/Child Filtering Behavior
- Customer sub group options are filtered by
parentId === selectedCustomerGroup - Changing group clears the sub group when the selected child no longer belongs to the new parent
- Placeholder shows
Select customer group firstuntil a parent group is chosen
7. Validation Added
- API schemas now accept
customerSubGroup - Server validation checks that:
- the selected sub group exists in
crm_customer_sub_group - a sub group cannot be submitted without a group
- the selected sub group belongs to the selected group parent
- the selected sub group exists in
- Invalid parent/child combinations return a user-safe
400error
8. Verification Result
npx tsc --noEmitpassed- CRUD wiring, list/detail output, and form filtering compile successfully
9. Remaining Risks
- Database migration
drizzle/0011_brief_hobgoblin.sqlstill needs to be applied in the target environment - Seed changes were updated in code, but I did not run a live seed against the database in this session
- Existing customer rows will keep
customerSubGroup = nulluntil edited or backfilled