diff --git a/src/app/structure-list/components/search/search.component.ts b/src/app/structure-list/components/search/search.component.ts index dffac930fbe2517ee3ae8483b3ee0f21a182c16b..b743d1cfd0760270fd73e7ebdd4e2ad279559ed3 100644 --- a/src/app/structure-list/components/search/search.component.ts +++ b/src/app/structure-list/components/search/search.component.ts @@ -184,38 +184,41 @@ export class SearchComponent implements OnInit, OnChanges { // Get the correct list of checkbox/modules depending on the type of modal. private getData(option: TypeModal): void { if (option === TypeModal.accompaniment) { - forkJoin([this.searchService.getCategoriesAccompaniment(), this.searchService.getFakeCounterModule()]).subscribe( - (res) => { - const categories: Category[] = res[0]; - const structureCounter: StructureCounter[] = res[1]; - categories.forEach((category) => { - category = this.searchService.setCountModules(category, structureCounter); - this.categories.push(category); - }); - } - ); + forkJoin([ + this.searchService.getCategoriesAccompaniment(), + this.searchService.getFakeCounterModule(this.checkedModulesFilter), + ]).subscribe((res) => { + const categories: Category[] = res[0]; + const structureCounter: StructureCounter[] = res[1]; + categories.forEach((category) => { + category = this.searchService.setCountModules(category, structureCounter); + this.categories.push(category); + }); + }); } else if (option === TypeModal.training) { - forkJoin([this.searchService.getCategoriesTraining(), this.searchService.getFakeCounterModule()]).subscribe( - (res) => { - const categories: Category[] = res[0]; - const structureCounter: StructureCounter[] = res[1]; - categories.forEach((category) => { - category = this.searchService.setCountModules(category, structureCounter); - this.categories.push(category); - }); - } - ); + forkJoin([ + this.searchService.getCategoriesTraining(), + this.searchService.getFakeCounterModule(this.checkedModulesFilter), + ]).subscribe((res) => { + const categories: Category[] = res[0]; + const structureCounter: StructureCounter[] = res[1]; + categories.forEach((category) => { + category = this.searchService.setCountModules(category, structureCounter); + this.categories.push(category); + }); + }); } else if (option === TypeModal.moreFilters) { - forkJoin([this.searchService.getCategoriesMoreFilters(), this.searchService.getFakeCounterModule()]).subscribe( - (res) => { - const categories: Category[] = res[0]; - const structureCounter: StructureCounter[] = res[1]; - categories.forEach((category) => { - category = this.searchService.setCountModules(category, structureCounter); - this.categories.push(category); - }); - } - ); + forkJoin([ + this.searchService.getCategoriesMoreFilters(), + this.searchService.getFakeCounterModule(this.checkedModulesFilter), + ]).subscribe((res) => { + const categories: Category[] = res[0]; + const structureCounter: StructureCounter[] = res[1]; + categories.forEach((category) => { + category = this.searchService.setCountModules(category, structureCounter); + this.categories.push(category); + }); + }); } } } diff --git a/src/app/structure-list/services/search.service.ts b/src/app/structure-list/services/search.service.ts index 2c2b58e37ad26ba60f432ac6a8728e1e9d23b254..8436bc53fea9cf4d5e12b69ad299da68ddb9f591 100644 --- a/src/app/structure-list/services/search.service.ts +++ b/src/app/structure-list/services/search.service.ts @@ -28,9 +28,9 @@ export class SearchService { .pipe(map((data: any[]) => data.map((item) => new Category(item)))); } - public getFakeCounterModule(): Observable<StructureCounter[]> { + public getFakeCounterModule(selectedFilters: { id: string; text: string }[]): Observable<StructureCounter[]> { return this.http - .get('/api/structures/count') + .post('/api/structures/count', selectedFilters) .pipe(map((data: any[]) => data.map((item) => new StructureCounter(item)))); } public setCountModules(category: Category, structureCountTab: StructureCounter[]): Category {