From 06326aa0bf41b47d85a42789b9cc7cb80e53b09e Mon Sep 17 00:00:00 2001 From: Spencer Ofwiti Date: Wed, 2 Jun 2021 12:59:37 +0300 Subject: [PATCH] Refactor patching of location and category information to autofil from bio and user location. --- src/app/_helpers/mock-backend.ts | 6 ++--- .../account-details.component.ts | 22 ++++++++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/app/_helpers/mock-backend.ts b/src/app/_helpers/mock-backend.ts index e89d7f2..5e500ba 100644 --- a/src/app/_helpers/mock-backend.ts +++ b/src/app/_helpers/mock-backend.ts @@ -1151,7 +1151,7 @@ export class MockBackendInterceptor implements HttpInterceptor { const queriedCategory: Category = categories.find((category) => category.products.includes(stringFromUrl()) ); - return ok(queriedCategory.name); + return ok(queriedCategory.name || 'other'); } function getAreaNames(): Observable> { @@ -1163,7 +1163,7 @@ export class MockBackendInterceptor implements HttpInterceptor { const queriedAreaName: AreaName = areaNames.find((areaName) => areaName.locations.includes(stringFromUrl()) ); - return ok(queriedAreaName.name); + return ok(queriedAreaName.name || 'other'); } function getAreaTypes(): Observable> { @@ -1175,7 +1175,7 @@ export class MockBackendInterceptor implements HttpInterceptor { const queriedAreaType: AreaType = areaTypes.find((areaType) => areaType.area.includes(stringFromUrl()) ); - return ok(queriedAreaType.name); + return ok(queriedAreaType.name || 'other'); } function getAccountTypes(): Observable> { diff --git a/src/app/pages/accounts/account-details/account-details.component.ts b/src/app/pages/accounts/account-details/account-details.component.ts index d6d9c95..5feca04 100644 --- a/src/app/pages/accounts/account-details/account-details.component.ts +++ b/src/app/pages/accounts/account-details/account-details.component.ts @@ -119,10 +119,26 @@ export class AccountDetailsComponent implements OnInit { type: this.account.type, bio: this.account.products, gender: this.account.gender, - businessCategory: this.account.category, + businessCategory: + this.account.category || + this.userService.getCategoryByProduct(this.account.products[0]), userLocation: this.account.location.area_name, - location: this.account.location.area, - locationType: this.account.location.area_type, + location: + this.account.location.area || + this.locationService + .getAreaNameByLocation(this.account.location.area_name) + .pipe(first()) + .subscribe((response) => { + return response; + }), + locationType: + this.account.location.area_type || + this.locationService + .getAreaTypeByArea(this.accountInfoFormStub.location.value) + .pipe(first()) + .subscribe((response) => { + return response; + }), }); this.userService .getAccountStatus(this.account.vcard?.tel[0].value)