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>
|
<p class="mb-1 fs-5 fw-semibold">Avis</p>
|
||||||
|
|
||||||
<div class="flex-column justify-content-start">
|
<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>
|
<button class="btn btn-success me-2" (click)="onSendRating()">Valider</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Component, Input, OnInit } from '@angular/core';
|
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-filter-side-bar',
|
selector: 'app-filter-side-bar',
|
||||||
@ -7,6 +7,8 @@ import { Component, Input, OnInit } from '@angular/core';
|
|||||||
})
|
})
|
||||||
export class FilterSideBarComponent implements OnInit {
|
export class FilterSideBarComponent implements OnInit {
|
||||||
@Input() listCategories: string[];
|
@Input() listCategories: string[];
|
||||||
|
@Output() stateNumber = new EventEmitter();
|
||||||
|
filterStateNumber: number = 0;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.listCategories = [];
|
this.listCategories = [];
|
||||||
@ -15,8 +17,12 @@ export class FilterSideBarComponent implements OnInit {
|
|||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onStateNumberChange(stateNumber: number): void {
|
||||||
|
this.filterStateNumber = stateNumber;
|
||||||
|
}
|
||||||
|
|
||||||
onSendRating():void {
|
onSendRating():void {
|
||||||
console.log("coucou");
|
this.stateNumber.emit(this.filterStateNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<div class="d-flex align-items-stretch">
|
<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">
|
<div class="custom-main container p-3">
|
||||||
<input class="form-control"
|
<input class="form-control"
|
||||||
|
@ -9,10 +9,12 @@ import * as _ from 'underscore';
|
|||||||
})
|
})
|
||||||
export class PageAccueilComponent implements OnInit {
|
export class PageAccueilComponent implements OnInit {
|
||||||
public listData: any[];
|
public listData: any[];
|
||||||
|
public listRate: any[];
|
||||||
public listCategoriesFilter: string[];
|
public listCategoriesFilter: string[];
|
||||||
|
|
||||||
constructor(private plantouneService: PlantouneService) {
|
constructor(private plantouneService: PlantouneService) {
|
||||||
this.listData = [];
|
this.listData = [];
|
||||||
|
this.listRate = [];
|
||||||
this.listCategoriesFilter = [];
|
this.listCategoriesFilter = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,6 +56,7 @@ export class PageAccueilComponent implements OnInit {
|
|||||||
this.listCategoriesFilter = listUniqJsCategories;
|
this.listCategoriesFilter = listUniqJsCategories;
|
||||||
this.listData = listPlant;
|
this.listData = listPlant;
|
||||||
this.listData.length = 9;
|
this.listData.length = 9;
|
||||||
|
console.log(this.listData);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -62,4 +65,15 @@ export class PageAccueilComponent implements OnInit {
|
|||||||
this.plantouneService.plantLiked$.next('')
|
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