diff --git a/src/app/notifier/notifier.component.css b/src/app/notifier/notifier.component.css
index 22d2b82..c78712a 100644
--- a/src/app/notifier/notifier.component.css
+++ b/src/app/notifier/notifier.component.css
@@ -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;
}
diff --git a/src/app/settings/settings.component.html b/src/app/settings/settings.component.html
index b053167..00e95c7 100644
--- a/src/app/settings/settings.component.html
+++ b/src/app/settings/settings.component.html
@@ -78,7 +78,7 @@
label="Integrations"
style="align-items: center;">
-
+
@@ -139,7 +139,7 @@
diff --git a/src/app/settings/settings.component.ts b/src/app/settings/settings.component.ts
index 6b951ce..de3d9fb 100644
--- a/src/app/settings/settings.component.ts
+++ b/src/app/settings/settings.component.ts
@@ -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 );
}
}
-
-
diff --git a/src/app/xero.service.ts b/src/app/xero.service.ts
index 5258d90..48a337f 100644
--- a/src/app/xero.service.ts
+++ b/src/app/xero.service.ts
@@ -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;
}
}