import { ReportType } from '@msfa-enums/report-type.enum';
import { ReportResponse } from './api/report.response.model';
import { PaginationMeta } from './pagination-meta.model';

export interface Report {
  id: string;
  genomforandeReferens: string;
  type: string;
  date: Date;
  status: string;
  ciamUserId: string;
  motivation: string;
}

export interface ReportsData {
  data: Report[];
  meta: PaginationMeta;
}

export function mapResponseToReport(data: ReportResponse): Report {
  const { id, genomforandeReferens, typAvRapport, inskickadDatum, statusRapport, ciamUserId, motivation } = data;
  return {
    id,
    genomforandeReferens,
    type: (ReportType[typAvRapport] as string) || 'Okänd',
    date: new Date(inskickadDatum),
    status: statusRapport,
    ciamUserId,
    motivation,
  };
}
