connect api to stock page for get, patch and delete

This commit is contained in:
2025-11-29 23:14:04 +01:00
parent a76b184dc1
commit 0189fb0440
8 changed files with 255 additions and 78 deletions

View File

@@ -1,11 +1,11 @@
<div class="flex mt-2">
@if (hasSelection) {
<app-modal-button type="default" name="Créer un bon de commande" class="ml-4">
<app-purchase-order-form></app-purchase-order-form>
<app-modal-button #modalButton type="default" name="Créer un bon de commande" class="ml-4">
<app-purchase-order-form #purchaseOrderForm></app-purchase-order-form>
</app-modal-button>
<app-modal-button type="default" name="Créer un devis" class="ml-4">
<app-quotation-form></app-quotation-form>
<app-modal-button #modalButton type="default" name="Créer un devis" class="ml-4" (click)="test()">
<app-quotation-form #quotationForm></app-quotation-form>
</app-modal-button>
}
@@ -15,7 +15,5 @@
</div>
<div class="mt-1">
<app-stock-table
(selectionChange)="onSelectionChange($event)"
></app-stock-table>
<app-stock-table #stockTable (selectionChange)="onSelectionChange($event)"></app-stock-table>
</div>

View File

@@ -1,9 +1,12 @@
import { Component } from '@angular/core';
import {Component, inject, viewChild} from '@angular/core';
import {StockTable} from "../../components/stock-table/stock-table";
import {Search} from "../../components/search/search";
import {ModalButton} from "../../components/modal-button/modal-button";
import {PurchaseOrderForm} from "../../components/purchase-order-form/purchase-order-form";
import {QuotationForm} from "../../components/quotation-form/quotation-form";
import {ProductsService} from "../../services/api";
import {NzNotificationService} from "ng-zorro-antd/notification";
import {firstValueFrom} from "rxjs";
@Component({
selector: 'app-stock',
@@ -19,10 +22,56 @@ import {QuotationForm} from "../../components/quotation-form/quotation-form";
})
export class Stock {
modal = viewChild.required<ModalButton>('modalButton');
createQuotation = viewChild.required<QuotationForm>('quotationForm');
createPurchaseOrder = viewChild.required<PurchaseOrderForm>('purchaseOrderForm');
productTable = viewChild.required<StockTable>('stockTable');
private productsService = inject(ProductsService);
private notificationService = inject(NzNotificationService)
// async onModalOk() {
// await this.addSupplier()
// this.createSupplier().supplierForm.reset();
// this.modal().isVisible = false;
// await this.supplierTable().fetchSuppliers()
// }
//
// onModalCancel() {
// this.modal().isVisible = false;
// }
//
// async addSupplier() {
// if (this.createSupplier().supplierForm.invalid)
// {
// this.notificationService.error(
// 'Erreur',
// 'Erreur d\'écriture dans le formulaire'
// )
// }
// try {
// const suppliers = this.createSupplier().supplierForm.getRawValue();
// await firstValueFrom(this.usersService.createSupplierEndpoint(suppliers))
//
// this.notificationService.success(
// 'Success',
// 'Fournisseur enregistré'
// )
// } catch (e) {
// this.notificationService.error(
// 'Erreur',
// 'Erreur d\'enregistrement'
// )
// }
// }
hasSelection = false;
onSelectionChange(value: boolean) {
this.hasSelection = value;
}
test(){
console.log(this.productTable().selectedIds);
}
}

View File

@@ -22,7 +22,7 @@ export class Supplier {
modal = viewChild.required<ModalButton>('modalButton');
createSupplier = viewChild.required<SupplierForm>('supplierForm');
supplierTable = viewChild.required<SupplierTable>('supplierTable');
private usersService = inject(SuppliersService);
private suppliersService = inject(SuppliersService);
private notificationService = inject(NzNotificationService)
async onModalOk() {
@@ -46,7 +46,7 @@ export class Supplier {
}
try {
const suppliers = this.createSupplier().supplierForm.getRawValue();
await firstValueFrom(this.usersService.createSupplierEndpoint(suppliers))
await firstValueFrom(this.suppliersService.createSupplierEndpoint(suppliers))
this.notificationService.success(
'Success',