Browse Source

feat(client): enforce immutability

pull/7080/head
KenTandrian 4 weeks ago
parent
commit
be8f63bbf0
  1. 33
      apps/client/src/app/pages/accounts/transfer-balance/transfer-balance-dialog.component.ts

33
apps/client/src/app/pages/accounts/transfer-balance/transfer-balance-dialog.component.ts

@ -42,31 +42,26 @@ import {
templateUrl: 'transfer-balance-dialog.html' templateUrl: 'transfer-balance-dialog.html'
}) })
export class GfTransferBalanceDialogComponent { export class GfTransferBalanceDialogComponent {
protected accounts: Account[] = []; protected readonly accounts: Account[] =
inject<TransferBalanceDialogParams>(MAT_DIALOG_DATA).accounts;
protected currency: string; protected currency: string;
protected transferBalanceForm: TransferBalanceForm;
private readonly data = inject<TransferBalanceDialogParams>(MAT_DIALOG_DATA); protected readonly transferBalanceForm: TransferBalanceForm = new FormGroup(
{
balance: new FormControl<number | string | null>('', Validators.required),
fromAccount: new FormControl<string | null>('', Validators.required),
toAccount: new FormControl<string | null>('', Validators.required)
},
{
validators: this.compareAccounts
}
);
private readonly dialogRef = private readonly dialogRef =
inject<MatDialogRef<GfTransferBalanceDialogComponent>>(MatDialogRef); inject<MatDialogRef<GfTransferBalanceDialogComponent>>(MatDialogRef);
public ngOnInit() { public ngOnInit() {
this.accounts = this.data.accounts;
this.transferBalanceForm = new FormGroup(
{
balance: new FormControl<number | string | null>(
'',
Validators.required
),
fromAccount: new FormControl<string | null>('', Validators.required),
toAccount: new FormControl<string | null>('', Validators.required)
},
{
validators: this.compareAccounts
}
);
this.transferBalanceForm.controls.fromAccount.valueChanges.subscribe( this.transferBalanceForm.controls.fromAccount.valueChanges.subscribe(
(id) => { (id) => {
const currency = this.accounts.find((account) => { const currency = this.accounts.find((account) => {

Loading…
Cancel
Save