import { IOption } from '@rh-support/types';
import map from 'lodash/map';

export function toOption<T>(value: T, labelKey?: string): IOption<T> {
  return value && { label: labelKey ? value[labelKey] : value, value };
}

export function toOptions<T>(values: T[], labelKey?: string): Array<IOption<T>> {
  return map(values, (v) => toOption(v, labelKey));
}
