import { ServiceEnum } from '@msfa-enums/service.enum';

export interface Service {
  id: string;
  name: string;
  tjanstekod: string;
  tjanstId: number;
  type: ServiceEnum;
}

export interface ServiceApiResponse {
  data: ServiceApiResponseData[];
}

export interface ServiceApiResponseData {
  id: string;
  name: string;
  tjanstekod: string;
  tjanstId: number;
  type: ServiceEnum;
}

export function mapServiceApiResponseToService(data: ServiceApiResponseData): Service {
  const { id, name, tjanstekod, tjanstId } = data;
  return {
    id,
    name,
    tjanstekod,
    tjanstId,
    type: getServiceEnumType(name),
  };
}

export function getServiceEnumType(name: string):ServiceEnum {
  switch (name) {
    case 'Kundval Rusta och matcha':
      return ServiceEnum.KROM;
    case 'Karriärvägledning':
      return ServiceEnum.KVL;
    case 'Stöd och Matchning':
      return ServiceEnum.STOM;
    default:
      break;
  }
}
