diff --git a/src/app/shared/categories-filter/categories-filter.component.ts b/src/app/shared/categories-filter/categories-filter.component.ts index 613a653c..43786942 100644 --- a/src/app/shared/categories-filter/categories-filter.component.ts +++ b/src/app/shared/categories-filter/categories-filter.component.ts @@ -72,32 +72,28 @@ export class CategoriesFilterComponent implements OnInit, OnDestroy { console.log('selected categories') console.log(this.selected) if(this.catalogId!=undefined){ - this.api.getCatalog(this.catalogId).then(data => { - if(data.category){ - for (let i=0; i { - this.findChildrenByParent(categoryInfo); - }) + let data = await this.api.getCatalog(this.catalogId); + if(data.category){ + for (let i=0; i { - for(let i=0; i < data.length; i++){ - this.findChildren(data[i],data) - } - this.cdr.detectChanges(); - initFlowbite(); - }) - } - }) + } } else { - await this.api.getLaunchedCategories().then(data => { - for(let i=0; i < data.length; i++){ - this.findChildren(data[i],data) - } - this.cdr.detectChanges(); - initFlowbite(); - }) + let data = await this.api.getLaunchedCategories() + for(let i=0; i < data.length; i++){ + this.findChildren(data[i],data) + } + this.cdr.detectChanges(); + initFlowbite(); } } @@ -125,9 +121,9 @@ export class CategoriesFilterComponent implements OnInit, OnDestroy { } } - findChildrenByParent(parent:any){ + async findChildrenByParent(parent:any){ let childs: any[] = [] - this.api.getCategoriesByParentId(parent.id).then(c => { + let c = await this.api.getCategoriesByParentId(parent.id) childs=c; parent["children"] = childs; if(parent.isRoot == true){ @@ -137,11 +133,10 @@ export class CategoriesFilterComponent implements OnInit, OnDestroy { } if(childs.length != 0){ for(let i=0; i < childs.length; i++){ - this.findChildrenByParent(childs[i]) + await this.findChildrenByParent(childs[i]) } } initFlowbite(); - }) }