feat(create-client): auto-link family member after client creation

- After creating a client from 'Create as Client' button, automatically
  call PUT /clients/{parentId}/familymembers/{memberId} with the new
  linkedClientId to link the family member record
- Show snackbar feedback on success or failure of the auto-link
- nomination-apply now also passes familyMemberId and parentClientId
  in prefill state so auto-link works from the nomination page too

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jaanu423
2026-06-23 10:40:00 +05:30
co-authored by Claude Sonnet 4.6
parent 10b301c30c
commit e59c3a14af
2 changed files with 32 additions and 2 deletions
@@ -35,6 +35,7 @@ import { FaIconComponent } from '@fortawesome/angular-fontawesome';
import { MatProgressSpinner } from '@angular/material/progress-spinner';
import { MatProgressBarModule } from '@angular/material/progress-bar';
import { MatDialog, MAT_DIALOG_DATA, MatDialogClose } from '@angular/material/dialog';
import { MatSnackBar } from '@angular/material/snack-bar';
import { MatTooltip } from '@angular/material/tooltip';
import { Inject } from '@angular/core';
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
@@ -71,6 +72,7 @@ export class CreateClientComponent {
private clientsService = inject(ClientsService);
private settingsService = inject(SettingsService);
private dialog = inject(MatDialog);
private snackBar = inject(MatSnackBar);
@ViewChild(ClientGeneralStepComponent) clientGeneralStep: ClientGeneralStepComponent;
@ViewChild('clientAddress') clientAddressStep: ClientAddressStepComponent;
@@ -520,7 +522,7 @@ export class CreateClientComponent {
* Finalize: upload photo/signature, save KYC, save addresses, then navigate.
*/
private finalizeClient(clientId: string) {
const navigateToClient = () =>
const doNavigate = () =>
this.router.navigate(
[
'../',
@@ -529,6 +531,32 @@ export class CreateClientComponent {
{ relativeTo: this.route }
);
const navigateToClient = () => {
const fm = this.prefillData;
if (fm?.familyMemberId && fm?.parentClientId) {
this.clientsService
.editFamilyMember(fm.parentClientId.toString(), fm.familyMemberId.toString(), {
linkedClientId: Number(clientId)
})
.subscribe({
next: () => {
this.snackBar.open('Family member linked to this client successfully.', 'Close', { duration: 4000 });
doNavigate();
},
error: () => {
this.snackBar.open(
'Client created, but family member could not be auto-linked. Please link manually.',
'Close',
{ duration: 6000 }
);
doNavigate();
}
});
} else {
doNavigate();
}
};
// Upload photo if selected
if (this.clientKycStep?.photographFile) {
this.clientsService
@@ -135,7 +135,9 @@ export class NominationApplyComponent implements OnInit {
mobileNo: member.mobileNumber || '',
dateOfBirth: member.dateOfBirth || null,
panNumber: member.panNumber || '',
aadhaarNumber: member.aadhaarNumber || ''
aadhaarNumber: member.aadhaarNumber || '',
familyMemberId: member.id,
parentClientId: this.selectedMemberId
};
this.router.navigate(
[