import { Pipe, PipeTransform } from '@angular/core';
import { OrderItemProcessingStatusValue } from '@swagger/oms';
import { ProcessingStatusNameMap } from '../constants';

@Pipe({
  name: 'processingStatus',
})
export class ProcessingStatusPipe implements PipeTransform {
  icon = {
    16: 'Check',
    128: 'Check',
    512: 'close',
    1024: 'close',
    2048: 'close',
  };

  transform(value: OrderItemProcessingStatusValue, type: 'icon' | 'text' = 'text'): string {
    return type === 'icon' ? this.icon[value] : ProcessingStatusNameMap.get(value) ? ProcessingStatusNameMap.get(value).value : '';
  }
}
