Chore:
Upgraded to Angular 14
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
import { Component, Inject } from '@angular/core';
|
||||
import { FormArray, FormBuilder, FormControl, FormGroup } from '@angular/forms';
|
||||
import {
|
||||
UntypedFormArray,
|
||||
UntypedFormBuilder,
|
||||
UntypedFormControl,
|
||||
UntypedFormGroup,
|
||||
} from '@angular/forms';
|
||||
import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { round } from 'mathjs';
|
||||
@@ -15,14 +20,14 @@ import { CustomerService } from '../../customers/customer.service';
|
||||
styleUrls: ['./choose-customer.component.css'],
|
||||
})
|
||||
export class ChooseCustomerComponent {
|
||||
form: FormGroup;
|
||||
form: UntypedFormGroup;
|
||||
item: Customer = new Customer();
|
||||
customers: Observable<Customer[]>;
|
||||
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<ChooseCustomerComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: string | undefined,
|
||||
private fb: FormBuilder,
|
||||
private fb: UntypedFormBuilder,
|
||||
private ser: CustomerService,
|
||||
) {
|
||||
// Create form
|
||||
@@ -34,7 +39,7 @@ export class ChooseCustomerComponent {
|
||||
discounts: this.fb.array([]),
|
||||
});
|
||||
// Setup Account Autocomplete
|
||||
this.customers = (this.form.get('phone') as FormControl).valueChanges.pipe(
|
||||
this.customers = (this.form.get('phone') as UntypedFormControl).valueChanges.pipe(
|
||||
startWith(null),
|
||||
map((x) => (x === this.item.phone ? '' : x)),
|
||||
map((x) => (x !== null && x.length >= 1 ? x : null)),
|
||||
@@ -93,7 +98,7 @@ export class ChooseCustomerComponent {
|
||||
this.item.phone = formModel.phone;
|
||||
this.item.address = formModel.address;
|
||||
this.item.printInBill = formModel.printInBill;
|
||||
const array = this.form.get('discounts') as FormArray;
|
||||
const array = this.form.get('discounts') as UntypedFormArray;
|
||||
this.item.discounts.forEach((item, index) => {
|
||||
item.discount = Math.max(
|
||||
Math.min(round(array.controls[index].value.discount / 100, 5), 100),
|
||||
|
||||
Reference in New Issue
Block a user