import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
  standalone: false,
  name: 'preferredPaymentMethod',
  pure: false
})
export class PreferredPaymentMethodPipe implements PipeTransform {
    transform(supplierValue: any, type: string): string {
        if (!supplierValue || !Array.isArray(supplierValue.payment_methods)) {
          return '';
        }

        const method = supplierValue.payment_methods.find((pm: any) => pm.type === type);
        return method ? method.name : '';
    }
}