import { Injectable, Pipe, PipeTransform } from '@angular/core';
import { OrderItemProcessingStatusValue } from '@swagger/oms';
import { ProcessingStatusNameMap } from '../constants/processing-status-name.map';

@Pipe({
  name: 'processingStatus',
})
@Injectable()
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 : '';
  }
}
