-
-
- Choisissez parmi les avis déjà donnés
-
-
+
+
+
+
+
+
+
+
+
+
+ Accès PMR
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Choisissez parmi les avis déjà donnés
+
+
+
+
+
-
-
+
\ No newline at end of file
diff --git a/src/app/pages/filters-page/filters-page.component.ts b/src/app/pages/filters-page/filters-page.component.ts
index d714295..2fac799 100644
--- a/src/app/pages/filters-page/filters-page.component.ts
+++ b/src/app/pages/filters-page/filters-page.component.ts
@@ -1,5 +1,5 @@
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
-import { Router } from '@angular/router';
+import { ActivatedRoute, Router } from '@angular/router';
import { ApiBackService } from 'src/app/services/api-back.service';
@Component({
@@ -14,7 +14,7 @@ export class FiltersPageComponent implements OnInit {
public minPrice : any;
public maxPrice: any;
- public selectPrice : any;
+ public selectPrice : number;
public selectDistance : any;
public selectPmr :any;
public selectSurPlace : any;
@@ -24,18 +24,18 @@ export class FiltersPageComponent implements OnInit {
@Output() rangeNumber = new EventEmitter();
public selectRating: number;
- public listRestau: string[];
+ public listRestau: any[];
- constructor(private apiBackService : ApiBackService, private route : Router) {
+ constructor(private apiBackService : ApiBackService, private route : Router, private activatedRoute : ActivatedRoute) {
this.minDistance = 0;
this.maxDistance = 4;
this.selectDistance = null;
- this.minPrice = 0;
- this.maxPrice = 20;
- this.selectPrice = null;
+ this.minPrice = 1;
+ this.maxPrice = 4;
+ this.selectPrice = 0;
this.selectPmr = false;
this.selectEmporter = false;
@@ -51,8 +51,10 @@ export class FiltersPageComponent implements OnInit {
ngOnInit(): void {
this.apiBackService.getRestaurants().subscribe((restaurants: any[]) => {
this.listRestau = restaurants;
- console.log(this.listRestau);
});
+
+ console.log(this.listRestau);
+
}
@@ -85,13 +87,22 @@ onSendRating() {
}
-onSendFilters(){
- console.log("Distance :" ,this.selectDistance);
- console.log("Prix :" ,this.selectPrice);
- console.log("Sur Place :" ,this.selectSurPlace);
- console.log("A emporter :" ,this.selectEmporter);
- console.log("PMR :" ,this.selectPmr);
- console.log("avis :" ,this.selectRating);
+onSendFilters() : void{
+ let restaus = this.listRestau;
+
+ restaus = restaus.filter((restau)=>
+
+ this.selectPrice == restau.prix
+
+ ),
+ console.log( this.activatedRoute.snapshot.routeConfig?.path);
+
+
+ this.apiBackService.setListRestau(restaus, this.activatedRoute.snapshot.routeConfig?.path);
+ // on fait passer en second parametre le path de la route c'est a dire "filtres"
+
+ this.route.navigate(['restaurants']);
+
}
}
diff --git a/src/app/pages/home-page/home-page.component.ts b/src/app/pages/home-page/home-page.component.ts
index ebb39f4..ffc4d14 100644
--- a/src/app/pages/home-page/home-page.component.ts
+++ b/src/app/pages/home-page/home-page.component.ts
@@ -18,16 +18,9 @@ export class HomePageComponent implements OnInit {
this.apiBackService.getCategories().subscribe((listCategories: any[]) => {
console.log(listCategories);
- // const listCategoriesLibelle = listCategories.map(
- // (category) => category.libelle
- // );
-
this.listCategories = listCategories;
- });
- console.log(this.apiBackService);
-
-
+ });
}
diff --git a/src/app/pages/resto-page/resto-page.component.ts b/src/app/pages/resto-page/resto-page.component.ts
index 848c180..38a2ac5 100644
--- a/src/app/pages/resto-page/resto-page.component.ts
+++ b/src/app/pages/resto-page/resto-page.component.ts
@@ -16,12 +16,22 @@ export class RestoPageComponent implements OnInit {
ngOnInit(): void {
+ // arrivée sur la restau-page depuis filtres ou home(catégories) : appel a une méthode différente du service
+ if(this.apiBackService.routeParam === "filtres"){
+ this.listRestaurants = this.apiBackService.restoFilter;
+
+ }else if(this.apiBackService.routeParam === "home"){
this.apiBackService.restoByCat.subscribe((restaurants: any[]) => {
-
this.listRestaurants = restaurants;
-
-
});
+ }else{ // si on arrive sur l'url /restaurants directement = tous les restau affichés
+
+ this.apiBackService.getRestaurants().subscribe((restaurants: any[]) => {
+ this.listRestaurants = restaurants;
+
+ })
+ }
+
}
diff --git a/src/app/services/api-back.service.ts b/src/app/services/api-back.service.ts
index 31c9dce..e38b7fb 100644
--- a/src/app/services/api-back.service.ts
+++ b/src/app/services/api-back.service.ts
@@ -9,22 +9,32 @@ import { environment } from 'src/environments/environment';
export class ApiBackService {
public restoByCat : Observable
= of([]);
+ public restoFilter : any[];
+ public routeParam ?: string;
constructor(private httpClient: HttpClient) {
+ this.restoFilter = [];
+ this.routeParam = "";
}
getRestaurants(): Observable {
return this.httpClient.get(`${environment.apiUrl}/restaurants`);
}
- getRestaurantsByCateg(id : number): void {
+ getRestaurantsByCateg(id : number, routeParam ?: string ): void {
this.restoByCat = this.httpClient.get(`${environment.apiUrl}/restaurantbytype/${id}`);
+ this.routeParam = routeParam;
}
getCategories(): Observable{
return this.httpClient.get(`${environment.apiUrl}/types`);
}
+ setListRestau(listRestau : any[], routeParam ?: string ) : void{
+ this.restoFilter = listRestau;
+ this.routeParam = routeParam;
+
+ }
}