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

@Pipe({
  name: 'changeProductName',
  standalone: false
})
export class ChangeProductNamePipe implements PipeTransform {

  transform(value: any, ...args: any): any {
    if (Object.keys(value).includes('name')) {
        value.product_name = value.name;
    }
    if (value.generic_or_brand != null && value.generic_or_brand.toLowerCase() === 'b'){
        value.productType = 'Brand';
        value.product_name = value.product_name + " | " + value.productType;
    }
    if (value.generic_or_brand != null && value.generic_or_brand.toLowerCase() === 'g'){
        value.productType = 'Generic';
        if(value.te_code !=='' || value.te_code !== undefined){
            value.product_name = value.product_name + " | " + value.te_code + " " +value.productType;
        } else {
            value.product_name = value.product_name + " | " + value.productType;
        }
    }
    return value.product_name;
  }

}
