Merge branch 'main' into feature/ajouter

This commit is contained in:
HarmandI 2022-03-21 18:59:04 +01:00
commit 4d93763aa5
4 changed files with 6068 additions and 6123 deletions

12175
db.json

File diff suppressed because it is too large Load Diff

View File

@ -23,7 +23,7 @@
<!-- <td>{{products.Catégorie.}}</td> -->
<td>{{products.rating}}</td>
<td><a class="bi-pencil-square" routerLink="../modifier"></a></td>
<td class="bi-trash-fill" style="color: red; cursor: pointer;" (click)="onClickDelete(5)"></td>
<td class="bi-trash-fill" style="color: red; cursor: pointer;" (click)="onClickDelete(products.id)"></td>
</tr>
</tbody>
</table>

View File

@ -28,8 +28,11 @@ export class PageTableauComponent implements OnInit {
// })
}
onClickDelete(id: number){
onClickDelete(id: any){
console.log(id);
this.adminService.onClickDelete(id).subscribe((resp) => {
console.log("Suppression successful : ", resp);
});
}

View File

@ -1,6 +1,6 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { map, Observable, Subject } from 'rxjs';
import { map, Observable, Subject, tap } from 'rxjs';
import { environment } from 'src/environments/environment';
import { Plant } from '../models/plant';
@ -40,6 +40,11 @@ export class AdminService {
addPlant(plant: Plant): Observable<any> | void {
return this.httpClient.post(`${this.apiUrl}`, plant);
}
onClickDelete(id: number): Observable<any> {
return this.httpClient.delete<any>(`${this.apiUrl}/list_products/${id}`).pipe(
tap(() => this.refreshCollection())
);
}
// getData(): Observable<any[]> {
// return this.httpClient.get<any[]>(`${this.apiUrl}/list_products`);
// }