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

export interface WorkExperience {
  profession: string;
  description: string;
  employer: string;
  dateFrom: Date;
  dateTo: Date;
}

export function mapResponseToWorkExperience(data: WorkExperienceResponse): WorkExperience {
  const { yrke, beskrivning, arbetsgivare, period_from, period_tom } = data;

  return {
    profession: yrke,
    description: beskrivning,
    employer: arbetsgivare,
    dateFrom: formatToDate(period_from),
    dateTo: formatToDate(period_tom),
  };
}
