import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core'; import { Table } from 'primeng/table'; import { PartnerCustomer } from '../models/partner-customer.model'; import { PartnerCustomerService } from '../services/partner-customer.service'; import { globals, Labels } from '@app/shared/global'; import { BaseComp } from '@app/shared/base/base.component'; import { AppMessageService } from '@app/shared/app-message.service'; import { getPackageDisplayName } from '@app/profile/common'; @Component({ selector: 'agm-partner-customer-list', templateUrl: './partner-customer-list.component.html', styleUrls: ['./partner-customer-list.component.css'] }) export class PartnerCustomerListComponent extends BaseComp implements OnInit, OnDestroy { partnerCustomers: PartnerCustomer[] = []; loading = false; cols: any[]; // Translation constants for template access readonly searchPlaceholder = Labels.SEARCH_PLACEHOLDER; @ViewChild('dt') dt: Table; constructor( private readonly partnerCustSvc: PartnerCustomerService, protected readonly msgSvc: AppMessageService ) { super(); this.cols = [ { field: 'name', header: globals.name, filtered: true, filterMatchMode: 'contains', width: '23%' }, { field: 'contactName', header: $localize`:Contact name column header@@contactName:Contact Name`, filtered: true, filterMatchMode: 'contains', width: '23%' }, { field: 'phone', header: globals.phone, filtered: true, filterMatchMode: 'contains', width: '16%' }, { field: 'email', header: globals.email, filtered: true, filterMatchMode: 'contains', width: '18%' }, { field: 'package', header: globals.package, filtered: true, filterMatchMode: 'contains', width: '20%' } ]; } ngOnInit() { this.loadPartnerCustomers(); } loadPartnerCustomers() { this.loading = true; this.partnerCustSvc.getPartnerCustomers().subscribe({ next: (customers) => { this.partnerCustomers = customers; this.loading = false; }, error: (error) => { this.msgSvc.addFailedMsg(Labels.ERROR_LOADING_PARTNER_CUSTOMERS); this.loading = false; } }); } reloadCustomers() { this.loadPartnerCustomers(); } /** * Get display name for package lookup key * @param lookupKey - Package lookup key (e.g., 'ess_1', 'ent_2') * @returns Descriptive name (e.g., 'Essential 1', 'Enterprise 2') */ getPackageName(lookupKey: string): string { return getPackageDisplayName(lookupKey); } ngOnDestroy() { super.ngOnDestroy(); } }