import { DisplayInfoDTO } from '@swagger/eis';
import { fromDisplayInfoToTask } from './task-mapper';
import { getColorForTask } from 'apps/sales/src/app/modules/task-calendar/helpers';
import { CalendarItem } from 'apps/sales/src/app/modules/task-calendar/defs';

export function fromDisplayInfoToCalendarItem(source: DisplayInfoDTO): CalendarItem {
  const task = fromDisplayInfoToTask(source);

  return {
    id: task.id,
    date: new Date(task.date),
    color: getColorForTask(task),
    title: task.title,
    type: task.type,
  };
}
