Upgraded to Angular 14
This commit is contained in:
2022-07-06 09:04:10 +05:30
parent f637f01954
commit 792ccf923f
46 changed files with 233 additions and 179 deletions
@@ -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),