ajout onRatingFilter
This commit is contained in:
parent
996674410a
commit
87824c5824
@ -36,7 +36,7 @@
|
||||
<p class="mb-1 fs-5 fw-semibold">Avis</p>
|
||||
|
||||
<div class="flex-column justify-content-start">
|
||||
<app-avis-bar></app-avis-bar>
|
||||
<app-avis-bar (stateNumber)="onStateNumberChange($event)"></app-avis-bar>
|
||||
<button class="btn btn-success me-2" (click)="onSendRating()">Valider</button>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-filter-side-bar',
|
||||
@ -7,6 +7,8 @@ import { Component, Input, OnInit } from '@angular/core';
|
||||
})
|
||||
export class FilterSideBarComponent implements OnInit {
|
||||
@Input() listCategories: string[];
|
||||
@Output() stateNumber = new EventEmitter();
|
||||
filterStateNumber: number = 0;
|
||||
|
||||
constructor() {
|
||||
this.listCategories = [];
|
||||
@ -15,8 +17,12 @@ export class FilterSideBarComponent implements OnInit {
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
onStateNumberChange(stateNumber: number): void {
|
||||
this.filterStateNumber = stateNumber;
|
||||
}
|
||||
|
||||
onSendRating():void {
|
||||
console.log("coucou");
|
||||
this.stateNumber.emit(this.filterStateNumber);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
<div class="d-flex align-items-stretch">
|
||||
<app-filter-side-bar [listCategories]="listCategoriesFilter"></app-filter-side-bar>
|
||||
<app-filter-side-bar [listCategories]="listCategoriesFilter" (stateNumber)="onRatingFilter($event)"></app-filter-side-bar>
|
||||
|
||||
<div class="custom-main container p-3">
|
||||
<input class="form-control"
|
||||
|
@ -9,10 +9,12 @@ import * as _ from 'underscore';
|
||||
})
|
||||
export class PageAccueilComponent implements OnInit {
|
||||
public listData: any[];
|
||||
public listRate: any[];
|
||||
public listCategoriesFilter: string[];
|
||||
|
||||
constructor(private plantouneService: PlantouneService) {
|
||||
this.listData = [];
|
||||
this.listRate = [];
|
||||
this.listCategoriesFilter = [];
|
||||
}
|
||||
|
||||
@ -54,6 +56,7 @@ export class PageAccueilComponent implements OnInit {
|
||||
this.listCategoriesFilter = listUniqJsCategories;
|
||||
this.listData = listPlant;
|
||||
this.listData.length = 9;
|
||||
console.log(this.listData);
|
||||
}
|
||||
)
|
||||
}
|
||||
@ -62,4 +65,15 @@ export class PageAccueilComponent implements OnInit {
|
||||
this.plantouneService.plantLiked$.next('')
|
||||
}
|
||||
|
||||
onRatingFilter(stateNumber: number): void {
|
||||
console.log(stateNumber);
|
||||
this.listData.forEach(product => {
|
||||
if(product.product_rating >= stateNumber) {
|
||||
this.listRate.push(product);
|
||||
}
|
||||
});
|
||||
this.listData = this.listRate;
|
||||
console.log(this.listData);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user