fix(deltagare): Changed the way addresses are handled. Now we show address-type even if no address is available. (TV-712)

Squashed commit of the following:

commit f49d49910dc335693f9c7825abbee59459f5d88b
Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se>
Date:   Thu Sep 30 08:43:15 2021 +0200

    Changed address handling inside contactinformation for deltagare
This commit is contained in:
Erik Tiekstra
2021-09-30 15:20:51 +02:00
parent dadc5b9bb6
commit 96a50a0b8e
3 changed files with 28 additions and 5 deletions

View File

@@ -12,7 +12,21 @@
ariaLabelType="personnummer" ariaLabelType="personnummer"
></msfa-hide-text> ></msfa-hide-text>
</dd> </dd>
<ng-container *ngFor="let address of contactInformation.addresses"> <dt>Folkbokföringsadress</dt>
<dd *ngIf="contactInformation.officialAddress as address; else emptyDD">
<address>
{{ address.street }}<br />
{{ address.postalCode }} {{ address.city }}
</address>
</dd>
<dt>Postadress</dt>
<dd *ngIf="contactInformation.postalAddress as address; else emptyDD">
<address>
{{ address.street }}<br />
{{ address.postalCode }} {{ address.city }}
</address>
</dd>
<!-- <ng-container *ngFor="let address of contactInformation.addresses">
<dt>{{address.type}}:</dt> <dt>{{address.type}}:</dt>
<dd> <dd>
<address> <address>
@@ -20,7 +34,7 @@
{{ address.postalCode }} {{ address.city }} {{ address.postalCode }} {{ address.city }}
</address> </address>
</dd> </dd>
</ng-container> </ng-container> -->
<dt>Telefon:</dt> <dt>Telefon:</dt>
<ng-container *ngIf="contactInformation.phoneNumbers?.length; else emptyDD"> <ng-container *ngIf="contactInformation.phoneNumbers?.length; else emptyDD">
<ng-container *ngFor="let phoneNumber of contactInformation.phoneNumbers"> <ng-container *ngFor="let phoneNumber of contactInformation.phoneNumbers">

View File

@@ -1,3 +1,4 @@
import { AddressType, getAddressType } from '@msfa-enums/address-type.enum';
import { mapStringToSsn } from '@msfa-utils/map-string-to-ssn.util'; import { mapStringToSsn } from '@msfa-utils/map-string-to-ssn.util';
import { Address, mapResponseToAddress } from './address.model'; import { Address, mapResponseToAddress } from './address.model';
import { ContactInformationResponse } from './api/contact-information.response.model'; import { ContactInformationResponse } from './api/contact-information.response.model';
@@ -10,11 +11,15 @@ export interface ContactInformation {
ssn: string; ssn: string;
email: string; email: string;
phoneNumbers: PhoneNumber[]; phoneNumbers: PhoneNumber[];
addresses: Address[]; // addresses: Address[];
officialAddress: Address;
postalAddress: Address;
} }
export function mapResponseToContactInformation(data: ContactInformationResponse): ContactInformation { export function mapResponseToContactInformation(data: ContactInformationResponse): ContactInformation {
const { fornamn, efternamn, personnummer, epost, telekomadresser, adresser } = data; const { fornamn, efternamn, personnummer, epost, telekomadresser, adresser } = data;
const officialAddress = adresser?.find(({ adresstyp }) => getAddressType(adresstyp) === AddressType.OFFICIAL);
const postalAddress = adresser?.find(({ adresstyp }) => getAddressType(adresstyp) === AddressType.POSTAL);
return { return {
firstName: fornamn || '', firstName: fornamn || '',
@@ -27,6 +32,8 @@ export function mapResponseToContactInformation(data: ContactInformationResponse
.filter(phoneNumber => phoneNumber.landskod && phoneNumber.nummer_utan_inledande_nolla) .filter(phoneNumber => phoneNumber.landskod && phoneNumber.nummer_utan_inledande_nolla)
.map(phoneNumber => mapResponseToPhoneNumber(phoneNumber)) .map(phoneNumber => mapResponseToPhoneNumber(phoneNumber))
: [], : [],
addresses: adresser ? adresser.map(address => mapResponseToAddress(address)) : null, officialAddress: officialAddress ? mapResponseToAddress(officialAddress) : null,
postalAddress: postalAddress ? mapResponseToAddress(postalAddress) : null,
// addresses: adresser ? adresser.map(address => mapResponseToAddress(address)) : null,
}; };
} }

View File

@@ -32,7 +32,9 @@ export interface Deltagare {
ssn: string; ssn: string;
email: string; email: string;
phoneNumbers: PhoneNumber[]; phoneNumbers: PhoneNumber[];
addresses: Address[]; officialAddress: Address;
postalAddress: Address;
// addresses: Address[];
driversLicense: DriversLicense; driversLicense: DriversLicense;
educations: Education[]; educations: Education[];
highestEducation: HighestEducation; highestEducation: HighestEducation;