- |
- |
- |
+ {{ purchaseOrder.id }} |
+ {{purchaseOrder.purchaseConditions}} |
+ Fournisseur ??? |
-
+
| Nom |
+ Reférence |
Prix |
Quantité |
Action |
- @for (product of data.productOrder; track product) {
+ @for (product of purchaseOrder.getPurchaseProductDto; track product.productId) {
- | {{product.product.name}} |
- {{product.price}}€ |
+ {{product.productName}} |
+ {{product.productReferences}} |
+ Prix €€€€ |
{{product.quantity}} |
|
@@ -52,12 +54,16 @@
+
+
+
+
-
+
@@ -65,7 +71,7 @@
-
+
|
diff --git a/src/app/components/purchase-order-table/purchase-order-table.ts b/src/app/components/purchase-order-table/purchase-order-table.ts
index ee9c5a3..1c50fe0 100644
--- a/src/app/components/purchase-order-table/purchase-order-table.ts
+++ b/src/app/components/purchase-order-table/purchase-order-table.ts
@@ -1,12 +1,14 @@
-import { Component } from '@angular/core';
+import {Component, inject, OnInit, signal} from '@angular/core';
import {ModalNav} from "../modal-nav/modal-nav";
import {NzDividerComponent} from "ng-zorro-antd/divider";
import {NzIconDirective} from "ng-zorro-antd/icon";
import {NzTableComponent} from "ng-zorro-antd/table";
-import {PurchaseOrderInfo} from "../../interfaces/purchase-order.interface";
import {PurchaseOrderForm} from "../purchase-order-form/purchase-order-form";
import {ModalButton} from "../modal-button/modal-button";
import {ProductForm} from "../product-form/product-form";
+import {GetPurchaseOrderDto, PurchaseordersService} from "../../services/api";
+import {NzNotificationService} from "ng-zorro-antd/notification";
+import {firstValueFrom} from "rxjs";
@Component({
selector: 'app-purchase-order-table',
@@ -22,172 +24,52 @@ import {ProductForm} from "../product-form/product-form";
templateUrl: './purchase-order-table.html',
styleUrl: './purchase-order-table.css',
})
-export class PurchaseOrderTable {
- purchaseOrders: PurchaseOrderInfo[] = [
- {
- purchaseCondition: "Condition d'achat standard 1",
- supplier: {
- name: "Fournisseur 1",
- email: "contact1@example.com",
- phone: "0100000001",
- address: "1 Rue de Paris",
- zipCode: "75001",
- city: "Paris",
- deliveryDelay: 3,
- products: [
- {
- reference: "F1-P1",
- name: "Produit 1A",
- supplier: [],
- duration: 0,
- caliber: "",
- approvalNumber: "",
- weight: 1,
- nec: 0,
- image: "",
- link: "",
- minimalQuantity: 1
- },
- {
- reference: "F1-P2",
- name: "Produit 1B",
- supplier: [],
- duration: 0,
- caliber: "",
- approvalNumber: "",
- weight: 2,
- nec: 0,
- image: "",
- link: "",
- minimalQuantity: 1
- }
- ]
- },
- productOrder: [
- {
- product: {
- reference: "F1-P1",
- name: "Produit 1A",
- supplier: [],
- duration: 0,
- caliber: "",
- approvalNumber: "",
- weight: 1,
- nec: 0,
- image: "",
- link: "",
- minimalQuantity: 1
- },
- quantity: 5,
- price: 10
- },
- {
- product: {
- reference: "F1-P2",
- name: "Produit 1B",
- supplier: [],
- duration: 0,
- caliber: "",
- approvalNumber: "",
- weight: 2,
- nec: 0,
- image: "",
- link: "",
- minimalQuantity: 1
- },
- quantity: 3,
- price: 15
- }
- ]
- },
+export class PurchaseOrderTable implements OnInit {
+ private purchaseOrdersService = inject(PurchaseordersService);
+ private notificationService = inject(NzNotificationService)
+ purchaseOrders = signal([]);
+ purchaseOrdersLoading = signal(false);
- {
- purchaseCondition: "Condition d'achat standard 2",
- supplier: {
- name: "Fournisseur 2",
- email: "contact2@example.com",
- phone: "0100000002",
- address: "2 Rue de Lyon",
- zipCode: "75002",
- city: "Paris",
- deliveryDelay: 4,
- products: [
- {
- reference: "F2-P1",
- name: "Produit 2A",
- supplier: [],
- duration: 0,
- caliber: "",
- approvalNumber: "",
- weight: 1.5,
- nec: 0,
- image: "",
- link: "",
- minimalQuantity: 1
- },
- {
- reference: "F2-P2",
- name: "Produit 2B",
- supplier: [],
- duration: 0,
- caliber: "",
- approvalNumber: "",
- weight: 2.5,
- nec: 0,
- image: "",
- link: "",
- minimalQuantity: 1
- }
- ]
- },
- productOrder: [
- {
- product: {
- reference: "F2-P1",
- name: "Produit 2A",
- supplier: [],
- duration: 0,
- caliber: "",
- approvalNumber: "",
- weight: 1.5,
- nec: 0,
- image: "",
- link: "",
- minimalQuantity: 1
- },
- quantity: 6,
- price: 11
- },
- {
- product: {
- reference: "F2-P2",
- name: "Produit 2B",
- supplier: [],
- duration: 0,
- caliber: "",
- approvalNumber: "",
- weight: 2.5,
- nec: 0,
- image: "",
- link: "",
- minimalQuantity: 1
- },
- quantity: 4,
- price: 16
- }
- ]
- },
- ];
+ async ngOnInit() {
+ await this.fetchPurchaseOrder();
+ }
- delete() {
- return
+ async fetchPurchaseOrder() {
+ this.purchaseOrdersLoading.set(true)
+
+ try {
+ const purchaseOrders = await firstValueFrom(this.purchaseOrdersService.getAllPurchaseOrderEndpoint())
+ this.purchaseOrders.set(purchaseOrders);
+ } catch (e) {
+ this.notificationService.error(
+ 'Erreur',
+ 'Erreur de communication avec l\'API'
+ )
+ }
+ this.purchaseOrdersLoading.set(false)
+ }
+
+ async delete(purchaseOrderId:number) {
+ try {
+ await firstValueFrom(this.purchaseOrdersService.deletePurchaseOrderEndpoint(purchaseOrderId))
+ this.notificationService.success(
+ 'Success',
+ 'Suppression effectuée'
+ )
+ } catch (e) {
+ this.notificationService.error(
+ 'Erreur',
+ 'Impossible de supprimer la ligne'
+ )
+ }
+ await this.fetchPurchaseOrder();
}
export(){
return
}
- transfert() {
+ transfer() {
return
}
}
|