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
@@ -62,6 +62,22 @@
</div>
}
<!-- Mother requirement — shown independently of the Father/Caretaker check below -->
@if (!nomineeOnly && clientFamilyMembers.length > 0 && !hasMother) {
<div class="fm-step__empty fm-step__empty--required">
<mat-icon class="fm-step__empty-icon">error_outline</mat-icon>
<span class="fm-step__empty-required">Mother is required.</span>
</div>
}
<!-- Father-or-Caretaker requirement — shown independently of the Mother check above -->
@if (!nomineeOnly && clientFamilyMembers.length > 0 && !hasFather && !hasCaretaker) {
<div class="fm-step__empty fm-step__empty--required">
<mat-icon class="fm-step__empty-icon">error_outline</mat-icon>
<span class="fm-step__empty-required">Either Father or a Caretaker is required.</span>
</div>
}
<!-- Spouse hint for married clients -->
@if (!nomineeOnly && isMarried && !hasSpouse) {
<div class="fm-spouse-hint">
@@ -223,6 +223,33 @@ export class ClientFamilyMembersStepComponent implements OnInit {
return this.clientFamilyMembers.length > 0;
}
/** True if a family member with the given relationship (case-insensitive) has been added */
private hasRelationship(name: string): boolean {
const target = name.toLowerCase();
return this.clientFamilyMembers.some((m: any) => {
const resolved = this.getRelName(m.relationshipId ?? m.relationship).toLowerCase();
if (resolved === target) return true;
return typeof m.relationship === 'string' && m.relationship.toLowerCase() === target;
});
}
get hasMother(): boolean {
return this.hasRelationship('mother');
}
get hasFather(): boolean {
return this.hasRelationship('father');
}
get hasCaretaker(): boolean {
return this.hasRelationship('caretaker');
}
/** Mother is always required; Father is required unless a Caretaker has been added instead. */
get familyRelationshipRulesMet(): boolean {
return this.hasMother && (this.hasFather || this.hasCaretaker);
}
/** Check if client's marital status is "Married" */
get isMarried(): boolean {
if (!this.maritalStatusId || !this.maritalStatusOptions?.length) return false;