diff --git a/src/app/modules/admin/components/formulaire/formulaire.component.html b/src/app/modules/admin/components/formulaire/formulaire.component.html index e8d5b46..3bdb12d 100644 --- a/src/app/modules/admin/components/formulaire/formulaire.component.html +++ b/src/app/modules/admin/components/formulaire/formulaire.component.html @@ -1,5 +1,5 @@
-
+
(); constructor(private fb : FormBuilder, private adminService: AdminService) { } @@ -28,10 +29,12 @@ export class FormulaireComponent implements OnInit { }); } - - - addPlant(){} - - updatePlant(){} + public onSubmit(): void { + this.submitted.emit(this.plantForm.value); + } +} + +function newEventEmitter() { + throw new Error('Function not implemented.'); } diff --git a/src/app/modules/admin/pages/page-ajouter/page-ajouter.component.html b/src/app/modules/admin/pages/page-ajouter/page-ajouter.component.html index 2521453..650250d 100644 --- a/src/app/modules/admin/pages/page-ajouter/page-ajouter.component.html +++ b/src/app/modules/admin/pages/page-ajouter/page-ajouter.component.html @@ -1,2 +1,2 @@

Ajouter une plante

- + diff --git a/src/app/modules/admin/pages/page-ajouter/page-ajouter.component.ts b/src/app/modules/admin/pages/page-ajouter/page-ajouter.component.ts index bda58f2..63662d3 100644 --- a/src/app/modules/admin/pages/page-ajouter/page-ajouter.component.ts +++ b/src/app/modules/admin/pages/page-ajouter/page-ajouter.component.ts @@ -21,6 +21,7 @@ import { AdminService } from '../../services/admin.service'; export class PageAjouterComponent implements OnInit { public plantForm: FormGroup; public isAdd: boolean = false; + public newplant = new Plant(); constructor(private fb: FormBuilder, private router: Router, private adminService: AdminService) { @@ -32,7 +33,7 @@ export class PageAjouterComponent implements OnInit { } - public onSubmit(): void { + public onSubmitted(submittedPlant: Plant): void { const nameValue = this.plantForm.value['nameFC']; const priceValue = this.plantForm.value['priceFc']; const quantityValue = this.plantForm.value['quantityFc']; @@ -43,18 +44,18 @@ export class PageAjouterComponent implements OnInit { const idValue = this.plantForm.value['']; const plant : Plant = { - name: nameValue, - price: priceValue, - quantity: quantityValue, - inStock: [inStockValue], - category: [categoryValue], - urlPicture: 'https//picsum.photos/id/18/200/300', - rating: ratingValue, + product_name: nameValue, + product_price: priceValue, + product_qty: quantityValue, + product_instock: [inStockValue], + product_breadcrumb_label: [categoryValue], + product_url_picture: 'https//picsum.photos/id/18/200/300', + product_rating: ratingValue, id: idValue, }; console.log("coco",plant); - this.adminService.addPlant(plant)?.subscribe((resp)=>{ + this.adminService.addPlant(submittedPlant)?.subscribe((resp)=>{ }) this.router.navigate(['admin']); } diff --git a/src/app/modules/admin/services/admin.service.ts b/src/app/modules/admin/services/admin.service.ts index aa94aa9..9b34b5b 100644 --- a/src/app/modules/admin/services/admin.service.ts +++ b/src/app/modules/admin/services/admin.service.ts @@ -38,7 +38,7 @@ export class AdminService { } addPlant(plant: Plant): Observable | void { - return this.httpClient.post(`${this.apiUrl}`, plant); + return this.httpClient.post(`${this.apiUrl}/list_products`, plant); } onClickDelete(id: number): Observable { return this.httpClient.delete(`${this.apiUrl}/list_products/${id}`).pipe(