updated models to cater for Content

This commit is contained in:
Daniel Appelgren
2021-12-14 11:34:55 +01:00
parent 8dc969ae45
commit 1d5825e8da
17 changed files with 122 additions and 67 deletions

View File

@@ -30,8 +30,8 @@ export class AvvikelseReportViewService {
switchMap(([reasons, questions]) => {
return this.handlingarApiService.fetchAvvikelseReport$(handlingId).pipe(
map(({ data }) => ({
genomforandeReferens: data.genomforandeReferens,
avvikelse: mapResponseToAvvikelse(data.avvikelseAlternativ, reasons, questions),
genomforandeReferens: data.content.genomforandeReferens,
avvikelse: mapResponseToAvvikelse(data.content.avvikelseAlternativ, reasons, questions),
}))
);
})

View File

@@ -31,8 +31,8 @@ export class FranvaroReportViewService {
switchMap(([reasons, otherReasons]) => {
return this.handlingarApiService.fetchFranvaroReport$(handlingId).pipe(
map(({ data }) => ({
genomforandeReferens: data.genomforandeReferens,
franvaro: mapResponseToFranvaro(data.franvaro, reasons, otherReasons),
genomforandeReferens: data.content.genomforandeReferens,
franvaro: mapResponseToFranvaro(data.content.franvaro, reasons, otherReasons, data.motivation, data.status),
}))
);
})

View File

@@ -5,6 +5,7 @@ import { DeltagareApiService } from '@msfa-services/api/deltagare.api.service';
import { HandlingarApiService } from '@msfa-services/api/handlingar.api.service';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { mapSlutredovisningResponseToSlutredovisning, Slutredovisning } from '@msfa-models/slutredovisning.model';
@Injectable()
export class SlutredovisningViewService {
@@ -14,7 +15,12 @@ export class SlutredovisningViewService {
return this.deltagareApiService.fetchAvropInformation$(genomforandeReferens);
}
public fetchSlutredovisning$(handlingId: string): Observable<SlutredovisningResponse> {
return this.handlingarApiService.fetchSlutredovisning$(handlingId).pipe(map(({ data }) => data));
public fetchSlutredovisning$(handlingId: string): Observable<Slutredovisning> {
return this.handlingarApiService.fetchSlutredovisning$(handlingId).pipe(
map(({ data }) => data),
map((slutredovisningResponse: SlutredovisningResponse) =>
mapSlutredovisningResponseToSlutredovisning(slutredovisningResponse)
)
);
}
}

View File

@@ -8,6 +8,10 @@ export interface AvvikelseResponse {
}
export interface AvvikelseReportResponse {
content: {
genomforandeReferens: number;
avvikelseAlternativ: AvvikelseResponse;
};
status?: string;
motivering?: string;
}

View File

@@ -15,6 +15,10 @@ export interface FranvaroResponse {
}
export interface FranvaroReportResponse {
content: {
genomforandeReferens: number;
franvaro: FranvaroResponse;
};
motivation?: string;
status?: string;
}

View File

@@ -2,4 +2,6 @@ export interface GemensamPlaneringResponse {
genomforandeReferens: string;
distans: boolean;
aktivitetsIds: number[];
status?: string;
motivation?: string;
}

View File

@@ -1,7 +1,11 @@
import { InformativRapportCategoryKey } from '@msfa-enums/informativ-rapport-category.enum';
export interface InformativRapportResponse {
content: {
genomforandeReferens: number;
category: InformativRapportCategoryKey;
comment: string;
};
motivation?: string;
status?: string;
}

View File

@@ -6,38 +6,13 @@ export interface PeriodiskRedovisningActivityResponse {
}
export interface PeriodiskRedovisningResponse {
content: {
genomforandeReferens: number;
period: string;
hasOfferedLanguageSupport: boolean;
hasOfferedJob: boolean;
activities: PeriodiskRedovisningActivityResponse[];
}
export function mockOnePeriodiskRedovisningResponse(): PeriodiskRedovisningResponse {
return {
genomforandeReferens: 100003857,
hasOfferedJob: false,
hasOfferedLanguageSupport: true,
period: '2021-10',
activities: [
{
id: 24,
performedRemotely: false,
performedPhysically: true,
hours: 25,
},
{
id: 19,
performedRemotely: true,
performedPhysically: false,
hours: 3,
},
{
id: 31,
performedRemotely: true,
performedPhysically: true,
hours: 2,
},
],
};
status?: string;
motivation?: string;
}

View File

@@ -9,9 +9,13 @@ export enum SignalResponseOmfattning {
}
export interface SignalResponse {
content: {
genomforandereferens: number;
type: SignalResponseType;
omfattning: SignalResponseOmfattning;
omfattningPercent: number;
startDate: string;
};
status?: string;
motivation?: string;
}

View File

@@ -65,12 +65,14 @@ export type SlutredovisningResponseMainOccupationDetails =
| SlutredovisningResponseMainOccupationStillUnemployed;
export interface SlutredovisningResponse {
content: {
genomforandereferens: number;
mainOccupation: SlutredovisningResponseMainOccupationDetails;
activities: { id: string; whatHasBeenDone: string; name: string }[];
progressDescription: string;
nextStepDescription: string;
otherInformation: string;
};
status?: string;
motivation?: string;
}

View File

@@ -9,6 +9,8 @@ export interface Avvikelse {
answer: string;
}[];
date: Date;
motivation?: string;
status?: string;
}
export interface AvvikelseReport {
@@ -19,7 +21,9 @@ export interface AvvikelseReport {
export function mapResponseToAvvikelse(
data: AvvikelseResponse,
reasons: AvvikelseReason[],
questions: AvvikelseQuestion[]
questions: AvvikelseQuestion[],
motivation?: string,
status?: string
): Avvikelse {
const { avvikelseOrsakskod, rapporteringsdatum, frageformular } = data;
@@ -30,5 +34,7 @@ export function mapResponseToAvvikelse(
answer: fraga.svar,
})),
date: new Date(rapporteringsdatum),
motivation,
status,
};
}

View File

@@ -11,6 +11,8 @@ export interface Franvaro {
expectedPresenceEndTime: string;
otherKnownReason: string;
knownReasonComment: string;
motivation?: string;
status?: string;
}
export interface FranvaroReport {
@@ -21,7 +23,9 @@ export interface FranvaroReport {
export function mapResponseToFranvaro(
data: FranvaroResponse,
reasons: FranvaroReason[],
otherKnownReasons: FranvaroReason[]
otherKnownReasons: FranvaroReason[],
motivation?: string,
status?: string
): Franvaro {
const { avvikelseOrsaksKod, datum, heldag, startTid, slutTid, alternativForKandaOrsaker, forvantadNarvaro } = data;
@@ -37,5 +41,7 @@ export function mapResponseToFranvaro(
knownReasonComment: alternativForKandaOrsaker?.motivering || null,
expectedPresenceStartTime: forvantadNarvaro.startTid,
expectedPresenceEndTime: forvantadNarvaro.slutTid,
motivation,
status,
};
}

View File

@@ -12,6 +12,8 @@ export interface GemensamPlaneringDetailed {
genomforandeReferens: number;
distance: boolean;
activities: string[];
status?: string;
motivation?: string;
}
export function mapGemensamPlaneringToGemensamPlaneringPostRequest(
@@ -30,11 +32,13 @@ export function mapResponseToGemensamPlaneringDetailed(
data: GemensamPlaneringResponse,
activities: Activity[]
): GemensamPlaneringDetailed {
const { genomforandeReferens, distans, aktivitetsIds } = data;
const { genomforandeReferens, distans, aktivitetsIds, status, motivation } = data;
return {
genomforandeReferens: +genomforandeReferens,
distance: distans,
activities: aktivitetsIds.map(id => activities.find(activity => activity.id === id).name),
status,
motivation,
};
}

View File

@@ -5,14 +5,18 @@ export interface InformativRapport {
genomforandeReferens: number;
category: InformativRapportCategory;
comment: string;
motivation?: string;
status?: string;
}
export function mapResponseToInformativRapport(data: InformativRapportResponse): InformativRapport {
const { genomforandeReferens, category, comment } = data;
const { genomforandeReferens, category, comment } = data.content;
return {
genomforandeReferens,
category: InformativRapportCategory[category] as InformativRapportCategory,
comment: comment,
motivation: data.motivation,
status: data.status,
};
}

View File

@@ -15,13 +15,15 @@ export interface PeriodiskRedovisning {
hasOfferedLanguageSupport: boolean;
hasOfferedJob: boolean;
activities: PeriodiskRedovisningActivity[];
motivation?: string;
status?: string;
}
export function mapResponseToPeriodiskRedovisning(
data: PeriodiskRedovisningResponse,
allActivities: Activity[]
): PeriodiskRedovisning {
const { genomforandeReferens, period, hasOfferedLanguageSupport, hasOfferedJob, activities } = data;
const { genomforandeReferens, period, hasOfferedLanguageSupport, hasOfferedJob, activities } = data.content;
return {
genomforandeReferens,
@@ -35,5 +37,7 @@ export function mapResponseToPeriodiskRedovisning(
performedPhysically,
hours,
})),
motivation: data.motivation,
status: data.status,
};
}

View File

@@ -1,7 +1,15 @@
import { SignalResponse } from './api/signal.response.model';
import { SignalResponse, SignalResponseOmfattning, SignalResponseType } from './api/signal.response.model';
export type Signal = SignalResponse;
export interface Signal {
genomforandereferens: number;
type: SignalResponseType;
omfattning: SignalResponseOmfattning;
omfattningPercent: number;
startDate: string;
status?: string;
motivation?: string;
}
export function mapResponseToSignal(data: SignalResponse): Signal {
return data;
return { motivation: data.motivation, status: data.status, ...data.content };
}

View File

@@ -1,4 +1,7 @@
import { SlutredovisningResponse } from '@msfa-models/api/slutredovisning.response.model';
import {
SlutredovisningResponse,
SlutredovisningResponseMainOccupationDetails,
} from '@msfa-models/api/slutredovisning.response.model';
export enum MainOccupation {
Work = 'work',
@@ -88,7 +91,26 @@ export function omfattningToString(omfattning: Omfattning): string | null {
}
}
export type Slutredovisning = SlutredovisningResponse;
export interface Slutredovisning {
genomforandereferens: number;
mainOccupation: SlutredovisningResponseMainOccupationDetails;
activities: { id: string; whatHasBeenDone: string; name: string }[];
progressDescription: string;
nextStepDescription: string;
otherInformation: string;
status?: string;
motivation?: string;
}
export function mapSlutredovisningResponseToSlutredovisning(
slutredovisningResponse: SlutredovisningResponse
): Slutredovisning {
return {
...slutredovisningResponse.content,
status: slutredovisningResponse.status,
motivation: slutredovisningResponse.motivation,
};
}
export function mainOccupationToString(mainOccupation: MainOccupation): string | null {
switch (mainOccupation) {