import { formatToDate } from '@msfa-utils/format-to-date.util';
import { EducationResponse } from './api/education.response.model';

export interface Education {
  education: string;
  description: string;
  organizer: string;
  dateFrom: Date;
  dateTo: Date;
}

export function mapResponseToEducation(data: EducationResponse): Education {
  const { utbildning, beskrivning, anordnare, period_from, period_tom } = data;

  return {
    education: utbildning,
    description: beskrivning,
    organizer: anordnare,
    dateFrom: formatToDate(period_from),
    dateTo: formatToDate(period_tom),
  };
}
