From 1b520593cd7efb55081371a89f6c73105c6139ee Mon Sep 17 00:00:00 2001 From: Thomas Cardon Date: Fri, 4 Feb 2022 14:13:52 +0100 Subject: [PATCH] Service restoByCat + icone --- .../card-category.component.html | 2 +- .../card-category/card-category.component.ts | 15 ++- src/app/card-resto/card-resto.component.html | 121 ++++++++++-------- src/app/card-resto/card-resto.component.ts | 6 +- .../resto-page/resto-page.component.html | 4 +- .../pages/resto-page/resto-page.component.ts | 14 +- src/app/services/api-back.service.ts | 11 +- 7 files changed, 110 insertions(+), 63 deletions(-) diff --git a/src/app/card-category/card-category.component.html b/src/app/card-category/card-category.component.html index 6b51e8c..3ddf1af 100644 --- a/src/app/card-category/card-category.component.html +++ b/src/app/card-category/card-category.component.html @@ -4,7 +4,7 @@
- {{ categoryData.libelle }} + {{ categoryData.libelle }}
\ No newline at end of file diff --git a/src/app/card-category/card-category.component.ts b/src/app/card-category/card-category.component.ts index 9709a30..1d495b8 100644 --- a/src/app/card-category/card-category.component.ts +++ b/src/app/card-category/card-category.component.ts @@ -1,4 +1,6 @@ import { Component, Input, OnInit } from '@angular/core'; +import { Router } from '@angular/router'; +import { ApiBackService } from '../services/api-back.service'; @Component({ selector: 'app-card-category', @@ -9,9 +11,20 @@ export class CardCategoryComponent implements OnInit { @Input() categoryData : any; - constructor() { } + constructor(private apiBackService : ApiBackService, private route : Router) { } ngOnInit(): void { } + onClickCateg(id : number){ + + + this.apiBackService.getRestaurantsByCateg(id); + + this.route.navigate(['restaurants']); + + //console.log('salut les copains'); + + } + } diff --git a/src/app/card-resto/card-resto.component.html b/src/app/card-resto/card-resto.component.html index 93cf94f..4345e94 100644 --- a/src/app/card-resto/card-resto.component.html +++ b/src/app/card-resto/card-resto.component.html @@ -1,58 +1,69 @@ -
- Card image cap -
- -
-
-

NOM RESTAURANT

- -
- -

- -

- -
-
- This is the first item's accordion body. -
-
    -
  • -
  • -
  • -
  • -
  • -
- 5/5 -
-
- Kebab - 550m - 5-10€ -
-
-

Descriptif : c’est le faux texte standard de l'imprimerie depuis - les années 1500, quand un imprimeur anonyme assembla ensemble des morceaux de texte pour - réaliser un livre spécimen de polices de texte.

-
-
- Sur place : - A emporter : -
-
-
- Accès PMR : -
-
- -
+
+ Card image cap +
+ +
+
+

{{ + restaurant.nom }}

+ +
+ +

+ +

+ +
+
+ This is the first item's accordion body. +
+
    +
  • +
  • +
  • +
  • +
  • +
+ 5/5
- +
+ Kebab + 550m + 5-10€ +
+
+

Descriptif : c’est le faux + texte standard de l'imprimerie depuis + les années 1500, quand un imprimeur anonyme assembla ensemble des morceaux de texte pour + réaliser un livre spécimen de polices de texte.

+
+
+ Sur place : + + + A emporter : +
+
+
+ Accès PMR : +
+
+ +
+
+
- -
-
- +
+
\ No newline at end of file diff --git a/src/app/card-resto/card-resto.component.ts b/src/app/card-resto/card-resto.component.ts index d5557fd..ed75d54 100644 --- a/src/app/card-resto/card-resto.component.ts +++ b/src/app/card-resto/card-resto.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, Input, OnInit } from '@angular/core'; @Component({ selector: 'app-card-resto', @@ -7,9 +7,13 @@ import { Component, OnInit } from '@angular/core'; }) export class CardRestoComponent implements OnInit { + @Input() restaurant : any ; + constructor() { } ngOnInit(): void { + console.log(this.restaurant); + } } diff --git a/src/app/pages/resto-page/resto-page.component.html b/src/app/pages/resto-page/resto-page.component.html index f907e34..d67ac0d 100644 --- a/src/app/pages/resto-page/resto-page.component.html +++ b/src/app/pages/resto-page/resto-page.component.html @@ -2,8 +2,8 @@

Résultats :

-
- +
+
diff --git a/src/app/pages/resto-page/resto-page.component.ts b/src/app/pages/resto-page/resto-page.component.ts index a0a5221..78dacce 100644 --- a/src/app/pages/resto-page/resto-page.component.ts +++ b/src/app/pages/resto-page/resto-page.component.ts @@ -1,4 +1,5 @@ import { Component, OnInit } from '@angular/core'; +import { ApiBackService } from 'src/app/services/api-back.service'; @Component({ selector: 'app-resto-page', @@ -7,9 +8,20 @@ import { Component, OnInit } from '@angular/core'; }) export class RestoPageComponent implements OnInit { - constructor() { } + public listRestaurants : any[]; + + constructor(private apiBackService : ApiBackService) { + this.listRestaurants = []; + } ngOnInit(): void { + + this.apiBackService.restoByCat.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 5104e04..31c9dce 100644 --- a/src/app/services/api-back.service.ts +++ b/src/app/services/api-back.service.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core'; -import { Observable, Subject } from 'rxjs'; +import { Observable, of, Subject } from 'rxjs'; import { HttpClient } from '@angular/common/http'; import { environment } from 'src/environments/environment'; @@ -8,12 +8,19 @@ import { environment } from 'src/environments/environment'; }) export class ApiBackService { - constructor(private httpClient: HttpClient) { } + public restoByCat : Observable = of([]); + + constructor(private httpClient: HttpClient) { + } getRestaurants(): Observable { return this.httpClient.get(`${environment.apiUrl}/restaurants`); } + getRestaurantsByCateg(id : number): void { + this.restoByCat = this.httpClient.get(`${environment.apiUrl}/restaurantbytype/${id}`); + } + getCategories(): Observable{ return this.httpClient.get(`${environment.apiUrl}/types`); }