Added supplier in purchase order form

This commit is contained in:
2026-05-26 19:17:40 +01:00
parent 14d3d25217
commit 56d3d1bea7
6 changed files with 49 additions and 30 deletions
@@ -1,14 +1,12 @@
import {Component, inject, OnInit, signal} from '@angular/core';
import {Component, input} from '@angular/core';
import {FormArray, FormControl, FormGroup, ReactiveFormsModule, Validators} from "@angular/forms";
import {GetProductDto, GetSupplierDto, SuppliersService} from "../../services/api";
import {GetProductDto, GetSupplierDto} from "../../services/api";
import {NzColDirective, NzRowDirective} from "ng-zorro-antd/grid";
import {NzFormControlComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
import {NzFlexDirective} from "ng-zorro-antd/flex";
import {NzTableComponent} from "ng-zorro-antd/table";
import {NzInputNumberComponent} from "ng-zorro-antd/input-number";
import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select";
import {firstValueFrom} from "rxjs";
import {NzNotificationService} from "ng-zorro-antd/notification";
@Component({
selector: 'app-add-product-supplier-form',
@@ -27,26 +25,13 @@ import {NzNotificationService} from "ng-zorro-antd/notification";
templateUrl: './add-product-supplier-form.html',
styleUrl: './add-product-supplier-form.css',
})
export class AddProductSupplierForm implements OnInit {
export class AddProductSupplierForm {
addProductForm: FormGroup = new FormGroup({
supplierId: new FormControl<number>(null, Validators.required),
lines: new FormArray([], Validators.required),
});
private suppliersServices = inject(SuppliersService);
private notificationService = inject(NzNotificationService);
suppliers = signal<GetSupplierDto[]>([]);
async ngOnInit() {
try {
const suppliers = await firstValueFrom(this.suppliersServices.getAllSuppliersEndpoint());
this.suppliers.set(suppliers);
}
catch {
this.notificationService.error('Erreur', 'Erreur de communication avec l\'API');
}
}
suppliers = input.required<GetSupplierDto[]>();
get lines(): FormArray {
return this.addProductForm.get('lines') as FormArray;