diff --git a/apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-report/pages/deltagare-avvikelse/deltagare-avvikelse.component.ts b/apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-report/pages/deltagare-avvikelse/deltagare-avvikelse.component.ts index e86abac..4caaaa5 100644 --- a/apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-report/pages/deltagare-avvikelse/deltagare-avvikelse.component.ts +++ b/apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-report/pages/deltagare-avvikelse/deltagare-avvikelse.component.ts @@ -8,13 +8,14 @@ import { ConfirmDialog } from '@msfa-enums/confirm-dialog.enum'; import { DayOrPartOfDay } from '@msfa-enums/day-or-part-of-day.enum'; import { FranvaroOrsaksKodEnum } from '@msfa-enums/franvaro-orsak-kod.enum'; import { KandaOrsakerEnum } from '@msfa-enums/kanda-orsaker-kod.enum'; -import { ContactInformationCompact } from '@msfa-models/api/contact-information.response.model'; import { AvvikelseAlternativ } from '@msfa-models/avvikelse-alternativ.model'; import { Avvikelse } from '@msfa-models/avvikelse.model'; +import { ContactInformation } from '@msfa-models/contact-information.model'; import { FragorForAvvikelser } from '@msfa-models/fragor-for-avvikelser.model'; import { FranvaroAlternativ } from '@msfa-models/franvaro-alternativ.model'; import { OrsaksKoderAvvikelse } from '@msfa-models/orsaks-koder-avvikelse.model'; import { KandaAvvikelseKoder, OrsaksKoderFranvaro } from '@msfa-models/orsaks-koder-franvaro.model'; +import { DeltagareApiService } from '@msfa-services/api/deltagare.api.service'; import { AnnanKandOrsakeIsRequiredCheck, DateIsRequiredCheck, @@ -52,9 +53,9 @@ export class DeltagareAvvikelseComponent implements OnInit { private _showSuccessNotification$ = new BehaviorSubject(false); private _showDangerNotification$ = new BehaviorSubject(false); - contactInformation$: Observable = this.activatedRoute.params.pipe( + contactInformation$: Observable = this.activatedRoute.params.pipe( switchMap(({ genomforandeReferens }) => - this.deltagareAvvikelseService.getContactInformationCompact$(genomforandeReferens) + this.deltagareApiService.fetchContactInformation$(genomforandeReferens) ) ); franvaroOrsaker$: Observable; @@ -62,7 +63,7 @@ export class DeltagareAvvikelseComponent implements OnInit { andraKandaOrsaker$: Observable; fragor1$: Observable; fragor2$: Observable; - contactInformation: ContactInformationCompact; + contactInformation: ContactInformation; sizeTextArea: FormTextareaSize.S; todayDate = new Date().toISOString().slice(0, 10); avvikelseAlternatives: RadiobuttonModel[] = avvikelseAlternatives; @@ -77,9 +78,10 @@ export class DeltagareAvvikelseComponent implements OnInit { constructor( private deltagareAvvikelseService: DeltagareAvvikelseService, + private deltagareApiService: DeltagareApiService, private router: Router, private activatedRoute: ActivatedRoute - ) {} + ) { } ngOnInit(): void { this.contactInformation$.pipe(first()).subscribe(contactInformation => { @@ -171,9 +173,9 @@ export class DeltagareAvvikelseComponent implements OnInit { const postAvvikelse: Avvikelse = { datum_for_rapportering: this.todayDate, arbetssokande: { - personnummer: this.contactInformation.personnummer.toString(), - fornamn: this.contactInformation.fornamn.toString(), - efternamn: this.contactInformation.efternamn.toString(), + personnummer: this.contactInformation.ssn, + fornamn: this.contactInformation.firstName, + efternamn: this.contactInformation.lastName, }, sokandeId: +this.activatedRoute.snapshot.params['genomforandeReferens'], }; diff --git a/apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-report/services/deltagare-avvikelse.service.ts b/apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-report/services/deltagare-avvikelse.service.ts index 6640f2a..293799e 100644 --- a/apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-report/services/deltagare-avvikelse.service.ts +++ b/apps/mina-sidor-fa/src/app/pages/deltagare/pages/deltagare-report/services/deltagare-avvikelse.service.ts @@ -1,6 +1,5 @@ import { Injectable } from '@angular/core'; import { FranvaroOrsaksKodEnum } from '@msfa-enums/franvaro-orsak-kod.enum'; -import { ContactInformationCompact } from '@msfa-models/api/contact-information.response.model'; import { Avvikelse } from '@msfa-models/avvikelse.model'; import { FragorForAvvikelser } from '@msfa-models/fragor-for-avvikelser.model'; import { OrsaksKoderAvvikelse } from '@msfa-models/orsaks-koder-avvikelse.model'; @@ -39,10 +38,6 @@ export class DeltagareAvvikelseService { return this.avvikelseApiService.createAvvikelse$(avvikelse, alternative); } - public getContactInformationCompact$(id: number): Observable { - return this.avvikelseApiService.getContactInformation$(id); - } - private sortOrsaksKoder(orsaksKoder: OrsaksKoderFranvaro[]): OrsaksKoderFranvaro[] { orsaksKoder.map(orsak => { if (+orsak.value == FranvaroOrsaksKodEnum.Sjuk) { diff --git a/apps/mina-sidor-fa/src/app/pages/deltagare/shared/report-layout/report-layout.component.html b/apps/mina-sidor-fa/src/app/pages/deltagare/shared/report-layout/report-layout.component.html index 3619211..5d23542 100644 --- a/apps/mina-sidor-fa/src/app/pages/deltagare/shared/report-layout/report-layout.component.html +++ b/apps/mina-sidor-fa/src/app/pages/deltagare/shared/report-layout/report-layout.component.html @@ -4,12 +4,12 @@

{{description}}

{{reportSubTitle}}

-
{{contactInformation.fornamn + ' ' + contactInformation.efternamn}}
+
{{contactInformation.firstName + ' ' + contactInformation.lastName}}
Personnummer:
diff --git a/apps/mina-sidor-fa/src/app/pages/deltagare/shared/report-layout/report-layout.component.ts b/apps/mina-sidor-fa/src/app/pages/deltagare/shared/report-layout/report-layout.component.ts index 9a115ae..124634d 100644 --- a/apps/mina-sidor-fa/src/app/pages/deltagare/shared/report-layout/report-layout.component.ts +++ b/apps/mina-sidor-fa/src/app/pages/deltagare/shared/report-layout/report-layout.component.ts @@ -1,9 +1,9 @@ import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; -import { ContactInformationCompact } from '@msfa-models/api/contact-information.response.model'; +import { ContactInformation } from '@msfa-models/contact-information.model'; +import { DeltagareApiService } from '@msfa-services/api/deltagare.api.service'; import { Observable } from 'rxjs'; import { switchMap } from 'rxjs/operators'; -import { DeltagareAvvikelseService } from '../../pages/deltagare-report/services/deltagare-avvikelse.service'; @Component({ selector: 'msfa-report-layout', @@ -24,11 +24,11 @@ export class ReportLayoutComponent { @Input() showSuccessNotification = false; @Input() showDangerNotification = false; - contactInformation$: Observable = this.activatedRoute.params.pipe( + contactInformation$: Observable = this.activatedRoute.params.pipe( switchMap(({ genomforandeReferens }) => - this.deltagareAvvikelseService.getContactInformationCompact$(genomforandeReferens) + this.deltagareApiService.fetchContactInformation$(genomforandeReferens) ) ); - constructor(private deltagareAvvikelseService: DeltagareAvvikelseService, private activatedRoute: ActivatedRoute) {} + constructor(private deltagareApiService: DeltagareApiService, private activatedRoute: ActivatedRoute) { } } diff --git a/apps/mina-sidor-fa/src/app/shared/models/api/contact-information.response.model.ts b/apps/mina-sidor-fa/src/app/shared/models/api/contact-information.response.model.ts index 203f1df..9e4949a 100644 --- a/apps/mina-sidor-fa/src/app/shared/models/api/contact-information.response.model.ts +++ b/apps/mina-sidor-fa/src/app/shared/models/api/contact-information.response.model.ts @@ -10,18 +10,3 @@ export interface ContactInformationResponse { adresser: AddressResponse[]; } -export interface ContactInformationCompact { - fornamn: string; - efternamn: string; - personnummer: string; -} - -export function mapResponseToContactInformationCompact(data: ContactInformationResponse): ContactInformationCompact { - const { fornamn, efternamn, personnummer } = data; - - return { - fornamn, - efternamn, - personnummer - } -} diff --git a/apps/mina-sidor-fa/src/app/shared/services/api/avvikelse-api.service.ts b/apps/mina-sidor-fa/src/app/shared/services/api/avvikelse-api.service.ts index 98c2a40..cba3595 100644 --- a/apps/mina-sidor-fa/src/app/shared/services/api/avvikelse-api.service.ts +++ b/apps/mina-sidor-fa/src/app/shared/services/api/avvikelse-api.service.ts @@ -3,17 +3,10 @@ import { Injectable } from '@angular/core'; import { Alternative } from '@msfa-enums/alternative.enum'; import { ErrorType } from '@msfa-enums/error-type.enum'; import { environment } from '@msfa-environment'; - -import { - ContactInformationCompact, - ContactInformationResponse, - mapResponseToContactInformationCompact -} from '@msfa-models/api/contact-information.response.model'; import { FragorForAvvikelserResponse } from '@msfa-models/api/fragor-for-avvikelser.response'; import { KandaAvvikelseKoderResponse } from '@msfa-models/api/kanda-avvikelse-koder.response.model'; import { OrsaksKoderAvvikelseResponse } from '@msfa-models/api/orsaks-koder-avvikelse.response.model'; import { Avvikelse, AvvikelseRequestData, mapAvvikelseRequestDataToAvvikelse } from '@msfa-models/avvikelse.model'; -import { errorToCustomError } from '@msfa-models/error/custom-error'; import { FragorForAvvikelser, mapResponseToFragorForAvvikelser } from '@msfa-models/fragor-for-avvikelser.model'; import { mapResponseToOrsaksKoderAvvikelse, OrsaksKoderAvvikelse } from '@msfa-models/orsaks-koder-avvikelse.model'; import { @@ -23,7 +16,7 @@ import { OrsaksKoderFranvaro } from '@msfa-models/orsaks-koder-franvaro.model'; import { ErrorService } from '@msfa-services/error.service'; -import { Observable, of, throwError } from 'rxjs'; +import { Observable, throwError } from 'rxjs'; import { catchError, filter, map, take } from 'rxjs/operators'; @Injectable({ @@ -62,18 +55,6 @@ export class AvvikelseApiService { ) } - public getContactInformation$(id: number): Observable { - return this.httpClient.get<{ data: ContactInformationResponse }>(`${this._apiBaseUrl}/deltagare/${id}/contact`).pipe( - filter(response => !!response?.data), - map(({ data }) => mapResponseToContactInformationCompact(data), - catchError(error => { - this.errorService.add(errorToCustomError(error)); - return of({}); - }) - ) - ) - } - public createAvvikelse$(avvikelse: Avvikelse, alternative: string): Observable { return this.httpClient @@ -103,7 +84,3 @@ export class AvvikelseApiService { constructor(private httpClient: HttpClient, private errorService: ErrorService) { } } - - - -