import { BranchInfoDTO } from '@swagger/isa';
import { Pipe, PipeTransform } from '@angular/core';
import { undefinedToEmptyStringOrValue } from 'apps/sales/src/app/core/utils/app.utils';

@Pipe({
  name: 'affiliateaddress',
})
export class AffiliateAddressPipe implements PipeTransform {
  transform(affiliate: BranchInfoDTO): string {
    if (affiliate == null) {
      return '';
    }
    return `${undefinedToEmptyStringOrValue(affiliate.name)} I ${undefinedToEmptyStringOrValue(
      affiliate.address.street
    )} ${undefinedToEmptyStringOrValue(affiliate.address.streetNumber)}, ${undefinedToEmptyStringOrValue(
      affiliate.address.zipCode
    )} ${undefinedToEmptyStringOrValue(affiliate.address.city)}`;
  }
}
