Added work-experience to deltagare service
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import { formatToIsoDate } from '@dafa-utils/format-to-iso-date.util';
|
||||||
import { EducationResponse } from './api/education.response.model';
|
import { EducationResponse } from './api/education.response.model';
|
||||||
|
|
||||||
export interface Education {
|
export interface Education {
|
||||||
@@ -15,7 +16,7 @@ export function mapResponseToEducation(data: EducationResponse): Education {
|
|||||||
education: utbildning,
|
education: utbildning,
|
||||||
description: beskrivning,
|
description: beskrivning,
|
||||||
organizer: anordnare,
|
organizer: anordnare,
|
||||||
dateFrom: period_from,
|
dateFrom: formatToIsoDate(period_from),
|
||||||
dateTo: period_tom,
|
dateTo: formatToIsoDate(period_tom),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { formatToIsoDate } from '@dafa-utils/format-to-iso-date.util';
|
||||||
import { WorkExperienceResponse } from './api/work-experience.response.model';
|
import { WorkExperienceResponse } from './api/work-experience.response.model';
|
||||||
|
|
||||||
export interface WorkExperience {
|
export interface WorkExperience {
|
||||||
@@ -15,7 +16,7 @@ export function mapResponseToWorkExperience(data: WorkExperienceResponse): WorkE
|
|||||||
profession: yrke,
|
profession: yrke,
|
||||||
description: beskrivning,
|
description: beskrivning,
|
||||||
employer: arbetsgivare,
|
employer: arbetsgivare,
|
||||||
dateFrom: period_from,
|
dateFrom: formatToIsoDate(period_from),
|
||||||
dateTo: period_tom,
|
dateTo: formatToIsoDate(period_tom),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import { Education, mapResponseToEducation } from '@dafa-models/education.model'
|
|||||||
import { HighestEducation, mapResponseToHighestEducation } from '@dafa-models/highest-education.model';
|
import { HighestEducation, mapResponseToHighestEducation } from '@dafa-models/highest-education.model';
|
||||||
import { mapResponseToWorkExperience, WorkExperience } from '@dafa-models/work-experience.model';
|
import { mapResponseToWorkExperience, WorkExperience } from '@dafa-models/work-experience.model';
|
||||||
import { combineLatest, Observable } from 'rxjs';
|
import { combineLatest, Observable } from 'rxjs';
|
||||||
import { map } from 'rxjs/operators';
|
import { map, tap } from 'rxjs/operators';
|
||||||
|
|
||||||
const API_HEADERS = { headers: environment.api.headers };
|
const API_HEADERS = { headers: environment.api.headers };
|
||||||
|
|
||||||
@@ -80,10 +80,11 @@ export class DeltagareService {
|
|||||||
}
|
}
|
||||||
private _fetchDisabilities$(id: string): Observable<Disability[]> {
|
private _fetchDisabilities$(id: string): Observable<Disability[]> {
|
||||||
return this.httpClient
|
return this.httpClient
|
||||||
.get<DisabilityResponse[]>(`${this._apiBaseUrl}/work/disability/${id}`, { ...API_HEADERS })
|
.get<DisabilityResponse[][]>(`${this._apiBaseUrl}/work/disability/${id}`, { ...API_HEADERS })
|
||||||
.pipe(
|
.pipe(
|
||||||
|
tap(response => console.log(response)),
|
||||||
map(response =>
|
map(response =>
|
||||||
response ? response.map(funktionsnedsattning => mapResponseToDisability(funktionsnedsattning)) : []
|
response ? response[0].map(funktionsnedsattning => mapResponseToDisability(funktionsnedsattning)) : []
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -102,7 +103,7 @@ export class DeltagareService {
|
|||||||
// }
|
// }
|
||||||
private _fetchWorkExperiences$(id: string): Observable<WorkExperience[]> {
|
private _fetchWorkExperiences$(id: string): Observable<WorkExperience[]> {
|
||||||
return this.httpClient
|
return this.httpClient
|
||||||
.get<{ data: WorkExperiencesResponse }>(`${this._apiBaseUrl}/work/${id}`, { ...API_HEADERS })
|
.get<{ data: WorkExperiencesResponse }>(`${this._apiBaseUrl}/work/experience/${id}`, { ...API_HEADERS })
|
||||||
.pipe(
|
.pipe(
|
||||||
map(response =>
|
map(response =>
|
||||||
response.data.arbetslivserfarenheter
|
response.data.arbetslivserfarenheter
|
||||||
@@ -133,16 +134,27 @@ export class DeltagareService {
|
|||||||
this._fetchTranslator$(id),
|
this._fetchTranslator$(id),
|
||||||
this._fetchWorkLanguages$(id),
|
this._fetchWorkLanguages$(id),
|
||||||
this._fetchDisabilities$(id),
|
this._fetchDisabilities$(id),
|
||||||
|
this._fetchWorkExperiences$(id),
|
||||||
]).pipe(
|
]).pipe(
|
||||||
map(
|
map(
|
||||||
([contactInformation, driversLicense, highestEducation, educations, translator, workLanguages, disabilities]: [
|
([
|
||||||
|
contactInformation,
|
||||||
|
driversLicense,
|
||||||
|
highestEducation,
|
||||||
|
educations,
|
||||||
|
translator,
|
||||||
|
workLanguages,
|
||||||
|
disabilities,
|
||||||
|
workExperiences,
|
||||||
|
]: [
|
||||||
ContactInformation,
|
ContactInformation,
|
||||||
DriversLicense,
|
DriversLicense,
|
||||||
HighestEducation,
|
HighestEducation,
|
||||||
Education[],
|
Education[],
|
||||||
string,
|
string,
|
||||||
string[],
|
string[],
|
||||||
Disability[]
|
Disability[],
|
||||||
|
WorkExperience[]
|
||||||
]) => ({
|
]) => ({
|
||||||
id,
|
id,
|
||||||
...contactInformation,
|
...contactInformation,
|
||||||
@@ -152,6 +164,7 @@ export class DeltagareService {
|
|||||||
translator,
|
translator,
|
||||||
workLanguages,
|
workLanguages,
|
||||||
disabilities,
|
disabilities,
|
||||||
|
workExperiences,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// Takes either 6 or 8 characters string (YYYYMMDD) and formats it to ISO standard (YYYY-MM-DD).
|
||||||
|
export function formatToIsoDate(date: string): string {
|
||||||
|
if (date.length === 6) {
|
||||||
|
return `${date.substring(0, 4)}-${date.substring(4)}`;
|
||||||
|
} else if (date.length === 8) {
|
||||||
|
return `${date.substring(0, 4)}-${date.substring(4, 6)}-${date.substring(6)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return date;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user