diff --git a/src/app/components/quotation-form/quotation-form.html b/src/app/components/quotation-form/quotation-form.html index 2716fab..0ca8812 100644 --- a/src/app/components/quotation-form/quotation-form.html +++ b/src/app/components/quotation-form/quotation-form.html @@ -1,4 +1,4 @@ -
+ Message du devis @@ -18,15 +18,5 @@ - - - - Fournisseur - - - - - -
diff --git a/src/app/components/quotation-form/quotation-form.ts b/src/app/components/quotation-form/quotation-form.ts index 6db611c..0e7a39c 100644 --- a/src/app/components/quotation-form/quotation-form.ts +++ b/src/app/components/quotation-form/quotation-form.ts @@ -26,15 +26,4 @@ export class QuotationForm { quotationMessage: new FormControl(null), quotationConditionsSale: new FormControl(null), }) - - submitForm() { - // Pour annuler si le formulaire est invalide - if (this.QuotationForm.invalid) return; - - // Pour obtenir la valeur du formulaire - console.log(this.QuotationForm.getRawValue()) - - // Pour vider le formulaire - this.QuotationForm.reset() - } } diff --git a/src/app/components/quotation-table/quotation-table.html b/src/app/components/quotation-table/quotation-table.html index 0d2ac21..c43bf62 100644 --- a/src/app/components/quotation-table/quotation-table.html +++ b/src/app/components/quotation-table/quotation-table.html @@ -1,22 +1,23 @@ - + Numéro de Devis Message Conditions de vente - Fournisseur Produit Action - @for (data of basicTable.data; track data) { + @for (quotation of quotations(); track quotation.id) { - {{data.quotationId}} - {{data.quotationMessage}} - {{data.quotationConditionsSale}} - {{data.Supplier}} - + {{quotation.id}} + {{quotation.message}} + {{quotation.conditionsSale}}
@@ -31,25 +32,19 @@ - + @for (product of quotation.getQuotationProductDto; track product.productId) { - {{data.quotationProductReference}} - {{data.quotationProductName}} - XX.XX€ - {{data.quotationProductQuantity}} + {{ product.productReferences }} + {{ product.productName }} + Price ??? + Quantité ???
- - - - -
- -
+
- + }
@@ -57,12 +52,16 @@
+
+ +
+
- +
diff --git a/src/app/components/quotation-table/quotation-table.ts b/src/app/components/quotation-table/quotation-table.ts index db47810..8bcb142 100644 --- a/src/app/components/quotation-table/quotation-table.ts +++ b/src/app/components/quotation-table/quotation-table.ts @@ -1,27 +1,13 @@ -import { Component } from '@angular/core'; +import {Component, inject, OnInit, signal} from '@angular/core'; import {NzTableComponent} from "ng-zorro-antd/table"; import {ModalButton} from "../modal-button/modal-button"; import {ModalNav} from "../modal-nav/modal-nav"; import {NzDividerComponent} from "ng-zorro-antd/divider"; import {NzIconDirective} from "ng-zorro-antd/icon"; import {QuotationForm} from "../quotation-form/quotation-form"; -import {ProductTable} from "../product-table/product-table"; -import {ProductForm} from "../product-form/product-form"; - -interface QuotationInfo { - quotationId: number; - quotationMessage?: string; - quotationConditionsSale?: string; - quotationProduct: [ - { quotationProductReference: string; }, - { quotationProductName: string; }, - { quotationProductQuantity?: number; }, - ], - quotationProductReference: string; - quotationProductName: string; - quotationProductQuantity?: number; - Supplier?: string; -} +import {GetQuotationDto, QuotationsService} from "../../services/api"; +import {NzNotificationService} from "ng-zorro-antd/notification"; +import {firstValueFrom} from "rxjs"; @Component({ selector: 'app-quotation-table', @@ -32,56 +18,50 @@ interface QuotationInfo { NzIconDirective, NzTableComponent, QuotationForm, - ProductForm ], templateUrl: './quotation-table.html', styleUrl: './quotation-table.css', }) -export class QuotationTable { - quotations: QuotationInfo[] = [ - { - quotationId: 101, - quotationMessage: 'Livraison urgente demandée', - quotationConditionsSale: 'Paiement à 30 jours', - quotationProduct: [ - { quotationProductReference: 'DLV-1000' }, - { quotationProductName: 'Produit1'}, - { quotationProductQuantity: 5 }, - ], - quotationProductReference: 'DLV-1000', - quotationProductName: 'Produit1', - quotationProductQuantity: 5, - Supplier: 'Fireworkssupplier&Co' - }, - { - quotationId: 102, - quotationMessage: 'Livraison standard', - quotationConditionsSale: 'Payé d\'avance', - quotationProduct: [ - { quotationProductReference: 'DLV-1001' }, - { quotationProductName: 'Produit2'}, - { quotationProductQuantity: 6 }, - ], - quotationProductReference: 'DLV-1001', - quotationProductName: 'Produit2', - quotationProductQuantity: 6, - Supplier: 'Fireworkssupplier&Co' - }, - { - quotationId: 103, - quotationMessage: 'Livraison rapide', - quotationConditionsSale: 'Paiement à 15 jours', - quotationProduct: [ - { quotationProductReference: 'DLV-1003' }, - { quotationProductName: 'Produit3'}, - { quotationProductQuantity: 7 }, - ], - quotationProductReference: 'DLV-1002', - quotationProductName: 'Produit3', - quotationProductQuantity: 7, - Supplier: 'Fireworkssupplier&Co' +export class QuotationTable implements OnInit { + private quotationsService = inject(QuotationsService); + private notificationService = inject(NzNotificationService) + quotations = signal([]); + quotationsLoading = signal(false); + + async ngOnInit() { + await this.fetchQuotations(); + } + + async fetchQuotations() { + this.quotationsLoading.set(true) + + try { + const quotations = await firstValueFrom(this.quotationsService.getAllQuotationEndpoint()) + this.quotations.set(quotations); + } catch (e) { + this.notificationService.error( + 'Erreur', + 'Erreur de communication avec l\'API' + ) } - ]; + this.quotationsLoading.set(false) + } + + async delete(quotation:number) { + try { + await firstValueFrom(this.quotationsService.deleteQuotationEndpoint(quotation)) + this.notificationService.success( + 'Success', + 'Suppression effectuée' + ) + } catch (e) { + this.notificationService.error( + 'Erreur', + 'Impossible de supprimer la ligne' + ) + } + await this.fetchQuotations(); + } } diff --git a/src/app/pages/quotation/quotation.html b/src/app/pages/quotation/quotation.html index 2edf3b6..92efc0e 100644 --- a/src/app/pages/quotation/quotation.html +++ b/src/app/pages/quotation/quotation.html @@ -1,8 +1,4 @@
- - - -