From efcd9578c1dc5c8f2b54784e28dd1557d370ce5d Mon Sep 17 00:00:00 2001 From: Leonardo Mendoza Date: Tue, 6 Jun 2023 13:16:35 -0600 Subject: [PATCH 1/2] 8662-qa-items-in-countries-modal-not-displayed-correctly-for-de-pl-and-tr-v2 --- .../record-countries.service.ts | 45 +++++++++++++------ 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/src/app/core/record-countries/record-countries.service.ts b/src/app/core/record-countries/record-countries.service.ts index c278cc9c24..fe4b506905 100644 --- a/src/app/core/record-countries/record-countries.service.ts +++ b/src/app/core/record-countries/record-countries.service.ts @@ -1,7 +1,7 @@ import { HttpClient, HttpHeaders } from '@angular/common/http' import { Injectable } from '@angular/core' import { forkJoin, merge, Observable, of, ReplaySubject } from 'rxjs' -import { retry, catchError, tap, map } from 'rxjs/operators' +import { retry, catchError, tap, map, take } from 'rxjs/operators' import { CountriesEndpoint } from 'src/app/types/record-country.endpoint' import { SideBarPublicUserRecord, @@ -10,6 +10,7 @@ import { import { environment } from 'src/environments/environment' import { ErrorHandlerService } from '../error-handler/error-handler.service' import { RecordPublicSideBarService } from '../record-public-side-bar/record-public-side-bar.service' +import { log } from 'console' @Injectable({ providedIn: 'root', @@ -299,17 +300,20 @@ export class RecordCountriesService { forceReload: false, } ): Observable { + console.log('here') if (options.publicRecordId) { return forkJoin([ - this._recordPublicSidebar.getPublicRecordSideBar(options), - this.getCountryCodes(), + this._recordPublicSidebar.getPublicRecordSideBar(options).pipe(take(1)), + this.getCountryCodes().pipe(take(1)), ]).pipe( map((value) => { const countries = value[0].countries const countryCodes = value[1] countries.addresses.forEach((country) => { //Override backend country name translations - country.countryName = countryCodes[country.iso2Country.value] || '' + country.countryName = + countryCodes.find((x) => x.value === country.iso2Country.value) + .key || '' }) return countries }) @@ -325,22 +329,37 @@ export class RecordCountriesService { this.$addresses.next(undefined) } - this._http - .get( - environment.API_WEB + `account/countryForm.json`, - { - headers: this.headers, - } - ) + forkJoin([ + this._http + .get( + environment.API_WEB + `account/countryForm.json`, + { + headers: this.headers, + } + ) + .pipe(take(1)), + this.getCountryCodes().pipe(take(1)), + ]) .pipe( retry(3), catchError((error) => this._errorHandler.handleError(error)), catchError(() => of({ addresses: [] } as CountriesEndpoint)), tap((value) => { - this.reverseSort(value) + this.reverseSort(value[0]) }), tap((value) => { - this.$addresses.next(value) + this.$addresses.next(value[0]) + }), + map((value) => { + const countries = value[0] as CountriesEndpoint + const countryCodes = value[1] as { key: string; value: string }[] + countries.addresses.forEach((country) => { + //Override backend country name translations + country.countryName = + countryCodes.find((x) => x.value === country.iso2Country.value) + .key || '' + }) + return countries }) ) .subscribe() From 8b6dc075dc7e3f94221cfaa58598e049855adcca Mon Sep 17 00:00:00 2001 From: Leonardo Mendoza Date: Tue, 6 Jun 2023 13:18:38 -0600 Subject: [PATCH 2/2] Remove logs --- src/app/core/record-countries/record-countries.service.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/app/core/record-countries/record-countries.service.ts b/src/app/core/record-countries/record-countries.service.ts index fe4b506905..95b4fe9d45 100644 --- a/src/app/core/record-countries/record-countries.service.ts +++ b/src/app/core/record-countries/record-countries.service.ts @@ -10,7 +10,6 @@ import { import { environment } from 'src/environments/environment' import { ErrorHandlerService } from '../error-handler/error-handler.service' import { RecordPublicSideBarService } from '../record-public-side-bar/record-public-side-bar.service' -import { log } from 'console' @Injectable({ providedIn: 'root', @@ -300,7 +299,6 @@ export class RecordCountriesService { forceReload: false, } ): Observable { - console.log('here') if (options.publicRecordId) { return forkJoin([ this._recordPublicSidebar.getPublicRecordSideBar(options).pipe(take(1)),