Settings component Save_Account button updated - testing version
This commit is contained in:
parent
87ef9ea10a
commit
12dbdd999d
4 changed files with 51 additions and 23 deletions
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ export class SettingsComponent implements OnInit {
|
|||
faCopy = faCopy;
|
||||
// ------------------------------------
|
||||
settingsForm: UntypedFormGroup;
|
||||
accCodForm: UntypedFormGroup;
|
||||
owner: Owner;
|
||||
useZats: boolean;
|
||||
proVersion: boolean = false;
|
||||
|
@ -73,9 +74,13 @@ export class SettingsComponent implements OnInit {
|
|||
currency: [data.currency, Validators.required],
|
||||
useZats: [data.zats, Validators.required],
|
||||
useVKey: [data.payconf, Validators.required],
|
||||
// proVersion: [data.invoices, 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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue