mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-28 22:42:11 +01:00
Merged PR 448: #1306 Adressanzeige Kundendetails
#1306 Adressanzeige Kundendetails
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { ChangeDetectorRef, Pipe, PipeTransform } from '@angular/core';
|
||||
import { CrmCustomerService } from '@domain/crm';
|
||||
import { AddressDTO, CommunicationDetailsDTO, OrganisationDTO } from '@swagger/crm';
|
||||
|
||||
export interface AddressData {
|
||||
@@ -20,7 +19,7 @@ export class AddressPipe implements PipeTransform {
|
||||
private result: string;
|
||||
private data: AddressData;
|
||||
|
||||
constructor(private customerService: CrmCustomerService, private cdr: ChangeDetectorRef) {}
|
||||
constructor(private cdr: ChangeDetectorRef) {}
|
||||
|
||||
transform(data: AddressData): string {
|
||||
this.data = data;
|
||||
@@ -32,10 +31,15 @@ export class AddressPipe implements PipeTransform {
|
||||
async getResult() {
|
||||
let result = undefined;
|
||||
if (!!this.data?.address?.street && !!this.data?.address?.city && !!this.data?.address?.zipCode && !!this.data?.address?.country) {
|
||||
const countries = await this.customerService.getCountries().toPromise();
|
||||
const country = countries.result.find((c) => c.isO3166_A_3 === this.data?.address.country)?.name || this.data?.address.country;
|
||||
|
||||
result = `${this.data?.address?.street} ${this.data?.address?.streetNumber}, ${this.data?.address?.zipCode} ${this.data?.address?.city}, ${country}`;
|
||||
let parts = [
|
||||
this.data?.organisation?.name || '',
|
||||
`${this.data?.lastName || ''}, ${this.data?.firstName || ''}`,
|
||||
`${this.data?.address?.street || ''} ${this.data?.address?.streetNumber || ''}`,
|
||||
`${this.data?.address?.zipCode || ''} ${this.data?.address?.city || ''}`,
|
||||
]
|
||||
.filter((value) => value != '')
|
||||
.filter((value) => value.trim());
|
||||
result = parts.join(' | ');
|
||||
}
|
||||
|
||||
if (result !== this.result) {
|
||||
|
||||
Reference in New Issue
Block a user