Fixed error to function to create purchase order
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {Component, input} from '@angular/core';
|
||||
import {
|
||||
FormArray,
|
||||
FormBuilder,
|
||||
@@ -34,6 +34,8 @@ import {GetProductDto} from "../../services/api";
|
||||
styleUrl: './create-quotation-form.css',
|
||||
})
|
||||
export class CreateQuotationForm {
|
||||
products = input.required<GetProductDto[]>();
|
||||
|
||||
createQuotationForm: FormGroup = new FormGroup({
|
||||
message: new FormControl<string>(null, Validators.required),
|
||||
purchaseConditions: new FormControl<string>(null, Validators.required),
|
||||
@@ -44,13 +46,13 @@ export class CreateQuotationForm {
|
||||
return this.createQuotationForm.get('lines') as FormArray;
|
||||
}
|
||||
|
||||
addProductToForm(selectedProducts: GetProductDto[]) {
|
||||
addProductToForm() {
|
||||
this.lines.clear();
|
||||
selectedProducts.forEach(p => {
|
||||
this.products().forEach(x => {
|
||||
this.lines.push(
|
||||
new FormGroup({
|
||||
productId: new FormControl(p.id),
|
||||
name: new FormControl(p.name),
|
||||
productId: new FormControl(x.id),
|
||||
name: new FormControl(x.name),
|
||||
quantity: new FormControl(0, [Validators.required, Validators.min(0)])
|
||||
})
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user