Refactor patching of location and category information to autofil from bio and user location.

This commit is contained in:
Spencer Ofwiti 2021-06-02 12:59:37 +03:00
parent 6904127876
commit 06326aa0bf
2 changed files with 22 additions and 6 deletions

View File

@ -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<HttpResponse<any>> {
@ -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<HttpResponse<any>> {
@ -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<HttpResponse<any>> {

View File

@ -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)