import { Injectable } from '@angular/core';
import { OrderByDTO } from '@swagger/cat';
import { FilterItem } from '../models/filter-item.model';
import { OptionDTO } from '@cmf/core';

@Injectable({ providedIn: 'root' })
export class FilterItemMapping {
  constructor() {}

  fromOptionDto(option: OptionDTO): FilterItem {
    return {
      id: option.value,
      name: option.label,
      selected: false,
    };
  }

  fromOrderByDto(orderBy: OrderByDTO): FilterItem {
    return {
      id: orderBy.by,
      name: orderBy.label,
      desc: orderBy.desc,
      selected: false,
    };
  }
}
