feat(clients): require Mother + Father/Caretaker as family members before activation

- Add hasMother/hasFather/hasCaretaker/familyRelationshipRulesMet to
  ClientFamilyMembersStepComponent, matched against the RELATIONSHIP code value label.
- Show two independent inline error banners (never merged into one message) when Mother, or
  both Father and Caretaker, are missing.
- Gate "Save & Next" and final Submit on this rule in both the create and edit client flows —
  the edit flow previously treated the Family tab as unconditionally optional.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-28 12:36:30 +05:30
co-authored by Claude Sonnet 5
parent 2e4187c3d2
commit 5fd7e1890e
4 changed files with 79 additions and 4 deletions
@@ -238,8 +238,8 @@ export class CreateClientComponent {
return this.isAddressStepValid();
}
if (idx === 3) {
// Family tab — relations are optional, always allow.
return true;
// Family tab — Mother is required, and either Father or a Caretaker.
return !this.clientFamilyMembersStep || this.clientFamilyMembersStep.familyRelationshipRulesMet;
}
}
return true;
@@ -273,6 +273,11 @@ export class CreateClientComponent {
return `Please fill/correct: ${labels.join(', ')}.`;
}
}
if (idx === 3 && this.legalFormType === 1 && this.clientFamilyMembersStep) {
const step = this.clientFamilyMembersStep;
if (!step.hasMother) return 'Mother is required as a family member.';
if (!step.hasFather && !step.hasCaretaker) return 'Either Father or a Caretaker is required as a family member.';
}
return 'Please fill all mandatory fields on this tab to continue.';
}
@@ -569,6 +574,21 @@ export class CreateClientComponent {
this.selectedTabIndex = 3;
return;
}
// Validate: Mother required, and either Father or a Caretaker (Individual clients)
if (
this.legalFormType === 1 &&
this.clientFamilyMembersStep &&
!this.clientFamilyMembersStep.familyRelationshipRulesMet
) {
const step = this.clientFamilyMembersStep;
if (!step.hasMother) {
this.validationError = 'Mother is required as a family member.';
} else {
this.validationError = 'Either Father or a Caretaker is required as a family member.';
}
this.selectedTabIndex = 3;
return;
}
this.validationError = '';
if (this.createdClientId) {