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

@ -9,7 +9,7 @@
.notifier-type {
border: 2px solid;
border-color: lightcoral;
background: #ff5722;
background: #ff5722;
font-size: 26px;
font-weight: 700;
height: 30px;
@ -21,17 +21,17 @@
}
::ng-deep .mat-snack-bar-container.error {
background: antiquewhite;
background: navajowhite;
color: red;
}
::ng-deep .mat-snack-bar-container.success {
background: whitesmoke;
background: whitesmoke;
color: black;
}
::ng-deep .mat-snack-bar-container.warning {
background: antiquewhite;
color: #fdebd0;
background: antiquewhite;
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;
@ -69,13 +70,17 @@ export class SettingsComponent implements OnInit {
this.useZats = data.zats;
this.useVKey = data.payconf;
this.settingsForm = fb.group({
name: [data.name, Validators.required],
currency: [data.currency, Validators.required],
useZats: [data.zats, Validators.required],
useVKey: [data.payconf, Validators.required],
// proVersion: [data.invoices, Validators.required],
vKey: [data.viewkey]
});
name: [data.name, Validators.required],
currency: [data.currency, Validators.required],
useZats: [data.zats, Validators.required],
useVKey: [data.payconf, Validators.required],
// 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;
}
}