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', imports: [ StockTable, Search, ModalButton, PurchaseOrderForm, QuotationForm, ], templateUrl: './stock.html', styleUrl: './stock.css', }) export class Stock { modal = viewChild.required('modalButton'); createQuotation = viewChild.required('quotationForm'); createPurchaseOrder = viewChild.required('purchaseOrderForm'); productTable = viewChild.required('stockTable'); private productsService = inject(ProductsService); private notificationService = inject(NzNotificationService) onProductSearch(query: string) { this.productTable().applySearch(query); } // 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); } }