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

@Pipe({
  name: 'assortment',
  pure: true,
})
export class AssortmentPipe implements PipeTransform {
  transform(value: string): { key: string; label: string } | undefined {
    const assortmentSplit = value?.split('|');
    if (assortmentSplit && assortmentSplit.length > 0) {
      return { key: assortmentSplit[1], label: assortmentSplit[0] };
    }

    return undefined;
  }
}
