Adjusted disability mock-data and service mapping to match api
This commit is contained in:
@@ -48,7 +48,10 @@
|
|||||||
<ng-container *ngIf="deltagare.disabilities; else emptyDD">
|
<ng-container *ngIf="deltagare.disabilities; else emptyDD">
|
||||||
<dd *ngFor="let disability of deltagare.disabilities">
|
<dd *ngFor="let disability of deltagare.disabilities">
|
||||||
<span>{{ disability.title }}</span>
|
<span>{{ disability.title }}</span>
|
||||||
<digi-ng-popover class="deltagare-card__popover" [afRelativeIconSize]="true"
|
<digi-ng-popover
|
||||||
|
*ngIf="disability.description"
|
||||||
|
class="deltagare-card__popover"
|
||||||
|
[afRelativeIconSize]="true"
|
||||||
>{{ disability.description }}</digi-ng-popover
|
>{{ disability.description }}</digi-ng-popover
|
||||||
>
|
>
|
||||||
</dd>
|
</dd>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export function mapResponseToDisability(data: DisabilityResponse): Disability {
|
|||||||
const { kod, funktionsnedsattning, beskrivning } = data;
|
const { kod, funktionsnedsattning, beskrivning } = data;
|
||||||
return {
|
return {
|
||||||
code: kod,
|
code: kod,
|
||||||
title: funktionsnedsattning, // TODO: Needed from API
|
title: funktionsnedsattning,
|
||||||
description: beskrivning, //TODO: Needed from API
|
description: beskrivning,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,28 +91,16 @@ export class DeltagareService {
|
|||||||
|
|
||||||
private _fetchDisabilities$(id: string): Observable<Disability[]> {
|
private _fetchDisabilities$(id: string): Observable<Disability[]> {
|
||||||
return this.httpClient
|
return this.httpClient
|
||||||
.get<{ data: DisabilityResponse[][] }>(`${this._apiBaseUrl}/work/disability/${id}`, { ...API_HEADERS })
|
.get<{ data: DisabilityResponse[] }>(`${this._apiBaseUrl}/work/disability/${id}`, { ...API_HEADERS })
|
||||||
.pipe(
|
.pipe(
|
||||||
map(response =>
|
map(response =>
|
||||||
response.data.length
|
response.data.length
|
||||||
? response.data[0].map(funktionsnedsattning => mapResponseToDisability(funktionsnedsattning))
|
? response.data.map(funktionsnedsattning => mapResponseToDisability(funktionsnedsattning))
|
||||||
: []
|
: []
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// private _fetchDisabilities$(id: string): Observable<Disability[]> {
|
|
||||||
// return this.httpClient
|
|
||||||
// .get<{ data: DisabilitiesResponse }>(`${this._apiBaseUrl}/work/disability/${id}`, { ...API_HEADERS })
|
|
||||||
// .pipe(
|
|
||||||
// map(respoqnse =>
|
|
||||||
// response.data.funktionsnedsattningar
|
|
||||||
// ? response.data.funktionsnedsattningar.map(funktionsnedsattning =>
|
|
||||||
// mapResponseToDisability(funktionsnedsattning)
|
|
||||||
// )
|
|
||||||
// : []
|
|
||||||
// )
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
private _fetchWorkExperiences$(id: string): Observable<WorkExperience[]> {
|
private _fetchWorkExperiences$(id: string): Observable<WorkExperience[]> {
|
||||||
return this.httpClient
|
return this.httpClient
|
||||||
.get<{ data: WorkExperiencesResponse }>(`${this._apiBaseUrl}/work/experience/${id}`, { ...API_HEADERS })
|
.get<{ data: WorkExperiencesResponse }>(`${this._apiBaseUrl}/work/experience/${id}`, { ...API_HEADERS })
|
||||||
|
|||||||
@@ -106,11 +106,7 @@ function generateDeltagare(amount = 10) {
|
|||||||
}))
|
}))
|
||||||
: [],
|
: [],
|
||||||
},
|
},
|
||||||
// disabilities: {
|
disabilities: Math.random() > 0.3 ? chooseRandom(DISABILITIES, faker.datatype.number(3)) : [],
|
||||||
// funktionsnedsattningar: Math.random() > 0.3 ? chooseRandom(DISABILITIES, faker.datatype.number(3)) : [],
|
|
||||||
// },
|
|
||||||
// TODO: Move to different structure. Temporary exposing disabilities in this structure as it is the way the API is exposing the data.
|
|
||||||
disabilities: [Math.random() > 0.3 ? chooseRandom(DISABILITIES, faker.datatype.number(3)) : []],
|
|
||||||
workExperiences: {
|
workExperiences: {
|
||||||
arbetslivserfarenheter: chooseRandom(WORK_EXPERIENCES, faker.datatype.number(WORK_EXPERIENCES.length)),
|
arbetslivserfarenheter: chooseRandom(WORK_EXPERIENCES, faker.datatype.number(WORK_EXPERIENCES.length)),
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user