import { Pipe, PipeTransform } from '@angular/core';
import { DBHOrderItemListItemDTO } from '@generated/swagger/oms-api';

@Pipe({
  name: 'coverCompartmentCode',
  standalone: true,
})
export class PickupShelfCoverCompartmentCodePipe implements PipeTransform {
  transform(item: DBHOrderItemListItemDTO): string {
    const compartmentCodeSplit = item.compartmentCode.split('_');
    compartmentCodeSplit.shift();
    const compartmentCode = compartmentCodeSplit.join('_');

    if (item.compartmentInfo) {
      return `${compartmentCode}_${item.compartmentInfo}`;
    }
    return compartmentCode;
  }
}
