import { ParticipantStatus } from '@msfa-enums/participant-status.enum';
import { ServiceEnum } from '@msfa-enums/service.enum';
import { PaginationMeta } from './pagination-meta.model';

export interface Participant {
  id: string;
  firstName: string;
  lastName: string;
  fullName: string;
  ssn: string;
  status: ParticipantStatus;
  nextStep: string;
  service: ServiceEnum;
  errandNumber: number;
  startDate: Date;
  endDate: Date;
  handleBefore: Date;
}

export interface ParticipantsApiResponse {
  data: ParticipantApiResponseData[];
  meta?: PaginationMeta;
}

export interface ParticipantApiResponse {
  data: ParticipantApiResponseData;
}

export interface ParticipantApiResponseData {
  id: string;
  firstName: string;
  lastName: string;
  ssn: string;
  status: ParticipantStatus;
  nextStep: string;
  service: ServiceEnum;
  errandNumber: number;
  startDate: Date;
  endDate: Date;
  handleBefore: Date;
}

export function mapParticipantApiResponseToParticipant(data: ParticipantApiResponseData): Participant {
  const {
    id,
    firstName,
    lastName,
    ssn,
    status,
    nextStep,
    service,
    errandNumber,
    startDate,
    endDate,
    handleBefore,
  } = data;
  return {
    id,
    firstName,
    lastName,
    fullName: `${firstName} ${lastName}`,
    ssn,
    status,
    nextStep,
    service,
    errandNumber,
    startDate,
    endDate,
    handleBefore,
  };
}
