diff --git a/src/app/notifier.service.ts b/src/app/notifier.service.ts index 95c8d9b..4e6b524 100644 --- a/src/app/notifier.service.ts +++ b/src/app/notifier.service.ts @@ -24,7 +24,7 @@ export class NotifierService { } playSound() { - console.log('Play sound called...'); +// console.log('Play sound called...'); let audio = new Audio(); audio.src = '../assets/notifier.mp3'; audio.load(); diff --git a/src/app/settings/settings.component.ts b/src/app/settings/settings.component.ts index de3d9fb..a134f74 100644 --- a/src/app/settings/settings.component.ts +++ b/src/app/settings/settings.component.ts @@ -60,6 +60,7 @@ export class SettingsComponent implements OnInit { accCodeUpdate: Observable; linked2Xero : boolean = false; pmtServiceURL : string = ''; + saveStat : boolean = false; constructor( private notifierService : NotifierService, @@ -180,25 +181,33 @@ 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'); - } + this.xeroService + .setXeroAccountCode(this.owner.address, + this.xeroAccCod); } else { this.notifierService .showNotification("Invalid Account code (10 chars max.)","Close",'error'); - } + }; + console.log("saveStat -> ",this.saveStat); + } + + checkSave( arg: any ) { + console.log("CheckSave -> " + arg); + this.saveStat = arg; +/* + if ( arg ) { + this.notifierService + .showNotification("Account saved correctly.)","Close",'success'); + } else { + this.notifierService + .showNotification("Account was not saved!!","Close",'error'); + } +*/ } xeroAccCodChanged( arg: any ) { diff --git a/src/app/xero.service.ts b/src/app/xero.service.ts index 48a337f..465da7e 100644 --- a/src/app/xero.service.ts +++ b/src/app/xero.service.ts @@ -21,6 +21,7 @@ export class XeroService { tokenType: '' }; xeroAcc: string = ''; + private _clientIdUpdated: BehaviorSubject = new BehaviorSubject(this.clientId); //private _clientSecretUpdated: BehaviorSubject = new BehaviorSubject(this.clientSecret); private _tokenUpdated: BehaviorSubject = new BehaviorSubject(this.xeroToken); @@ -77,19 +78,16 @@ export class XeroService { } - setXeroAccountCode(address: string, code: string) : boolean { - let res : boolean = false; + setXeroAccountCode(address: string, code: string) { + 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'}); + let obs = this.http.post(this.beUrl + 'api/xeroaccount', {}, {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 res; } }