WEB-655 feat(clients): filter datatables by client subtype (Person/Entity) (#3120)

This commit is contained in:
Shubham Kumar
2026-02-09 17:36:27 -06:00
committed by GitHub
parent 92342bb0a8
commit e8d1a1d5fe
@@ -24,6 +24,7 @@ import { CaptureImageDialogComponent } from './custom-dialogs/capture-image-dial
/** Custom Services */
import { ClientsService } from '../clients.service';
import { LegalFormId } from '../models/legal-form.enum';
import {
MatCard,
MatCardHeader,
@@ -144,11 +145,26 @@ export class ClientsViewComponent implements OnInit {
constructor() {
this.route.data.subscribe((data: { clientViewData: any; clientTemplateData: any; clientDatatables: any }) => {
this.clientViewData = data.clientViewData;
this.clientDatatables = data.clientDatatables;
this.clientDatatables = this.filterDatatablesByClientSubtype(
data.clientDatatables,
data.clientViewData?.legalForm?.id
);
this.clientTemplateData = data.clientTemplateData;
});
}
/**
* Filters datatables based on the client's legal form (Person or Entity).
* Datatables without an entitySubType are kept visible for all client types.
*/
private filterDatatablesByClientSubtype(datatables: any[], legalFormId: number): any[] {
if (!datatables || !legalFormId) {
return datatables || [];
}
const subtype = legalFormId === LegalFormId.PERSON ? 'person' : 'entity';
return datatables.filter((dt: any) => !dt.entitySubType || dt.entitySubType.toLowerCase() === subtype);
}
ngOnInit() {
this.clientsService.getClientProfileImage(this.clientViewData.id).subscribe({
next: (base64Image: any) => {