Skip to content
Snippets Groups Projects
Commit b99c290f authored by Antonin COQUET's avatar Antonin COQUET
Browse files

send actual filters and change endpoint

parent 099b8341
No related branches found
No related tags found
3 merge requests!178release V1.10.0,!120Dev,!114send actual filters and change endpoint
......@@ -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);
});
});
}
}
}
......@@ -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 {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment