Settings component Save_Account button updated - testing version

This commit is contained in:
Rene V. Vergara A. 2022-09-06 21:44:36 -05:00
parent 87ef9ea10a
commit 12dbdd999d
4 changed files with 51 additions and 23 deletions

View file

@ -21,7 +21,7 @@
}
::ng-deep .mat-snack-bar-container.error {
background: antiquewhite;
background: navajowhite;
color: red;
}
@ -32,6 +32,6 @@
::ng-deep .mat-snack-bar-container.warning {
background: antiquewhite;
color: #fdebd0;
color: black;
}

View file

@ -78,7 +78,7 @@
label="Integrations"
style="align-items: center;">
<div class="container" style="margin-bottom: 20px;">
<mat-dialog-content [formGroup]="settingsForm">
<mat-dialog-content [formGroup]="accCodForm">
<div style="height: 10px;
margin-top: 10px;">
</div>
@ -139,7 +139,7 @@
<input matInput
width="100%"
placeholder="9999999999"
formControlName="xeroAccCod"
formControlName="xAcc"
(change)="xeroAccCodChanged($event)">
</mat-form-field>

View file

@ -23,6 +23,7 @@ export class SettingsComponent implements OnInit {
faCopy = faCopy;
// ------------------------------------
settingsForm: UntypedFormGroup;
accCodForm: UntypedFormGroup;
owner: Owner;
useZats: boolean;
proVersion: boolean = false;
@ -76,6 +77,10 @@ export class SettingsComponent implements OnInit {
// proVersion: [data.invoices, Validators.required],
vKey: [data.viewkey]
});
this.accCodForm = fb.group ({
xAcc: [this.xeroAccCod]
});
if (data.payconf) {
this.settingsForm.get('vKey')!.enable();
}
@ -94,6 +99,8 @@ export class SettingsComponent implements OnInit {
xeroService.getXeroAccountCode(this.owner.address);
this.accCodeUpdate.subscribe(accData => {
this.xeroAccCod = accData;
console.log("xeroAccCod -> [" + this.xeroAccCod + "]");
this.accCodForm.get('xAcc')!.setValue(this.xeroAccCod);
});
}
@ -156,10 +163,6 @@ export class SettingsComponent implements OnInit {
}
saveAccCod() {
}
copyUrl() {
// console.log("Inside copyUrl()");
if (navigator.clipboard) {
@ -176,11 +179,31 @@ export class SettingsComponent implements OnInit {
}
}
saveAccCod() {
this.xeroAccCod = this.accCodForm.value.xAcc;
console.log(">>> " + this.xeroAccCod);
if ( this.xeroAccCod.length <= 10 ) {
const savedAcc = this.xeroService
.setXeroAccountCode(this.owner.address,
this.xeroAccCod );
console.log("savedAcc: " + JSON.stringify(savedAcc));
if ( savedAcc ) {
this.notifierService
.showNotification("Account saved correctly!!","Close",'success');
} else {
this.notifierService
.showNotification("Error while saving account code!!","Close",'error');
}
} else {
this.notifierService
.showNotification("Invalid Account code (10 chars max.)","Close",'error');
}
}
xeroAccCodChanged( arg: any ) {
// console.log("Account Code changed: " + arg.target.value);
// console.log(arg);
this.saveAccOk = (arg.target.value !== '');
this.saveAccOk = (arg.target.value != this.xeroAccCod );
}
}

View file

@ -77,14 +77,19 @@ export class XeroService {
}
setXeroAccountCode(address: string, code: string){
setXeroAccountCode(address: string, code: string) : boolean {
let res : boolean = false;
const params = new HttpParams().append('address', address).append('code', code);
let obs = this.http.post(this.beUrl + 'api/xerotoken', {}, {headers: this.reqHeaders, params: params, observe: 'response'});
obs.subscribe(responseData => {
if (responseData.status == 202) {
console.log('Account saved');
res = true;
}
}, error => {
console.log('Oops!! ',error.message);
res = false;
});
return obs;
return res;
}
}