ajout favoris sur pages categories
This commit is contained in:
parent
a7a53659f2
commit
d1a49dae32
|
@ -20,26 +20,27 @@ export class RestoPageComponent implements OnInit {
|
||||||
private tokenService : TokenService) {
|
private tokenService : TokenService) {
|
||||||
this.listRestaurants = [];
|
this.listRestaurants = [];
|
||||||
this.restaurantPref = [];
|
this.restaurantPref = [];
|
||||||
|
this.beforeRoute = this.apiBackService.routeParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
|
||||||
this.beforeRoute = this.apiBackService.routeParam;
|
this.restauLiked();
|
||||||
|
|
||||||
// arrivée sur la restau-page depuis filtres ou home(catégories) : appel a une méthode différente du service
|
// // 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"){
|
// if(this.apiBackService.routeParam === "filtres"){
|
||||||
this.listRestaurants = this.apiBackService.restoFilter;
|
// this.listRestaurants = this.apiBackService.restoFilter;
|
||||||
|
|
||||||
}else if(this.apiBackService.routeParam === "categories"){
|
// }else if(this.apiBackService.routeParam === "categories"){
|
||||||
this.apiBackService.restoByCat.subscribe((restaurants: any[]) => {
|
// this.apiBackService.restoByCat.subscribe((restaurants: any[]) => {
|
||||||
this.listRestaurants = restaurants;
|
// this.listRestaurants = restaurants;
|
||||||
});
|
// });
|
||||||
}else{ // si on arrive sur l'url /restaurants directement = tous les restau affichés
|
// }else{ // si on arrive sur l'url /restaurants directement = tous les restau affichés
|
||||||
|
|
||||||
|
|
||||||
this.restauLiked();
|
// this.restauLiked();
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,14 +51,23 @@ export class RestoPageComponent implements OnInit {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
restauLiked(){
|
restauLiked(){
|
||||||
|
|
||||||
forkJoin({
|
forkJoin({
|
||||||
restaurants: this.apiBackService.getRestaurants(),
|
restaurants: this.apiBackService.getRestaurants(),
|
||||||
user: this.apiBackService.getPersonneById(this.tokenService.getCurrentUserId())
|
user: this.apiBackService.getPersonneById(this.tokenService.getCurrentUserId()),
|
||||||
}).subscribe(({restaurants, user}) => {
|
restauByCat : this.apiBackService.restoByCat
|
||||||
|
}).subscribe(({restaurants, user, restauByCat}) => {
|
||||||
|
|
||||||
this.listRestaurants = restaurants;
|
|
||||||
|
if(this.beforeRoute === "filtres"){
|
||||||
|
this.listRestaurants = this.apiBackService.restoFilter;
|
||||||
|
}else if(this.beforeRoute === "categories" ){
|
||||||
|
this.listRestaurants = restauByCat
|
||||||
|
}else{
|
||||||
|
this.listRestaurants = restaurants;
|
||||||
|
}
|
||||||
|
|
||||||
this.listPref = user.preference;
|
this.listPref = user.preference;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue