Fixed error with code to check product

This commit is contained in:
2026-05-26 18:57:41 +01:00
parent 961551e926
commit 14d3d25217
5 changed files with 34 additions and 38 deletions
@@ -34,29 +34,26 @@ import {GetProductDto} from "../../services/api";
styleUrl: './create-quotation-form.css',
})
export class CreateQuotationForm {
createQuotationForm: FormGroup
constructor(private fb: FormBuilder) {
this.createQuotationForm = this.fb.group({
message: new FormControl<string>(null, Validators.required),
purchaseConditions: new FormControl<string>(null, Validators.required),
lines: this.fb.array([])
});
}
createQuotationForm: FormGroup = new FormGroup({
message: new FormControl<string>(null, Validators.required),
purchaseConditions: new FormControl<string>(null, Validators.required),
lines: new FormArray([], Validators.required),
})
get lines(): FormArray {
return this.createQuotationForm.get('lines') as FormArray;
}
// Ajouter des produits sélectionnés dans le formulaire
syncSelectedProducts(selectedProducts: GetProductDto[]) {
addProductToForm(selectedProducts: GetProductDto[]) {
this.lines.clear();
selectedProducts.forEach(p => {
this.lines.push(this.fb.group({
productId: [p.id],
name: [p.name],
quantity: [1, [Validators.required, Validators.min(1)]]
}));
this.lines.push(
new FormGroup({
productId: new FormControl(p.id),
name: new FormControl(p.name),
quantity: new FormControl(0, [Validators.required, Validators.min(0)])
})
);
});
}
}