Settings and ListOrders components updated

This commit is contained in:
Rene V. Vergara A. 2022-08-23 16:22:34 -05:00
parent 152bddca3b
commit 3053d17740
7 changed files with 76 additions and 9 deletions

View File

@ -10,7 +10,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Added new service for Xero integration
### Changed
- Settings component updated to use owner's invoices field to control
integrations tab (Pro version)
- Orders list updated to show payment confirmation only when service is
activated and a viewing key exists.
- Updated Order and Owner model to include new Xero integration fields
## [1.2.2] - 2022-08-05

View File

@ -44,10 +44,11 @@
<table width="100%">
<tr>
<td>
<fa-icon [icon]="getIcon(order)" [style]="getIconStyle(order)" ></fa-icon>
<fa-icon *ngIf="payConf"
[icon]="getIcon(order)" [style]="getIconStyle(order)" ></fa-icon>
</td>
<td align="center">
{{order.timestamp | date: 'short'}}
{{order.timestamp | date: 'MM/dd/YY, hh:mm a'}}
</td>
</tr>
</table>

View File

@ -30,7 +30,7 @@ export class ListOrdersComponent implements OnInit, OnDestroy{
public orders: Order[] = [];
public ownerUpdate: Observable<Owner>;
public ordersUpdate: Observable<Order[]>;
// ------------------------------------
//
@ -40,6 +40,32 @@ export class ListOrdersComponent implements OnInit, OnDestroy{
faCheckCircle = faCheckCircle;
faHourglass = faHourglass;
faTrash = faTrash;
payConf : boolean = false;
owner : Owner = {
address: '',
name: '',
currency: 'usd',
tax: false,
taxValue: 0,
vat: false,
vatValue: 0,
first: '',
last: '',
email: '',
street: '',
city: '',
state: '',
postal: '',
phone: '',
paid: false,
website: '',
country: '',
zats: false,
invoices: false,
expiration: new Date(Date.now()).toISOString(),
payconf: false,
viewkey: ''
};
// -------------------------------------
@ -55,13 +81,24 @@ export class ListOrdersComponent implements OnInit, OnDestroy{
}
ngOnInit(){
// console.log('listOrders Init -->');
this.owner = this.userService.currentOwner();
// console.log(this.owner.name);
this.payConf = this.owner.payconf;
// this.payConf = true;
// console.log('payConf = ', this.payConf);
this.ordersUpdate.subscribe((orders) => {
this.total = 0;
this.todayTotal = 0;
var today = new Date();
this.orders = orders;
console.log(this.ownerUpdate);
for (let i=0; i < this.orders.length; i++){
this.total += this.orders[i].totalZec;
//
var date = new Date(this.orders[i]!.timestamp!);
var diff = (today.getTime() / 1000) - (date.getTime()/1000);
if (diff < (24*3600)){

View File

@ -244,9 +244,16 @@ public order: Order = {
console.log('Invoice type is invalid' );
this.reportType = 5;
}
}, error => {
},
error => {
console.log("Error while getting invData!!!");
console.log(error);
console.log(error.status);
if ( error.status == 500 ) {
// Assume that invoice was not found by haskell server
this.reportType = 4;
}
});
}
@ -301,6 +308,9 @@ public order: Order = {
correctLevel: QRCode.CorrectLevel.H
});
}, error => {
console.log(error.message);
});
}

View File

@ -3,7 +3,7 @@
<div class="container"
style="margin-top: 10px;
height: 430px;
height: 450px;
margin-left: 10px;
margin-right: 10px;">
<mat-tab-group mat-tab-align-tabs="start">
@ -45,6 +45,12 @@
formControlName="vKey">
</textarea>
</mat-form-field>
<pre></pre>
<mat-slide-toggle formControlName="proVersion"
class="settings-toggle"
(change)="onChangeProVersion($event)">
Enable Integrations
</mat-slide-toggle>
</mat-dialog-content>
</div>
@ -67,7 +73,8 @@
margin-top: 10px;">
</div>
</mat-tab>
<mat-tab label="Advanced"
<mat-tab *ngIf="proVersion"
label="Integrations"
style="align-items: center;">
<div style="height: 20px;
margin-top: 10px;">

View File

@ -17,6 +17,7 @@ export class SettingsComponent implements OnInit {
settingsForm: UntypedFormGroup;
owner: Owner;
useZats: boolean;
proVersion: boolean = false;
useVKey: boolean = false;
coins = [
{
@ -53,6 +54,7 @@ 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],
vKey: [data.viewkey]
});
if (data.payconf) {
@ -85,9 +87,8 @@ export class SettingsComponent implements OnInit {
this.owner.currency = this.settingsForm.value.currency;
this.owner.zats = this.settingsForm.value.useZats;
this.owner.payconf = this.settingsForm.value.useVKey;
this.owner.viewkey = this.settingsForm.value.vKey;
this.owner.invoices = this.settingsForm.value.proVersion
this.dialogRef.close(this.owner);
}
@ -95,6 +96,10 @@ export class SettingsComponent implements OnInit {
this.useZats = ob.checked;
}
onChangeProVersion(ob: MatSlideToggleChange) {
this.proVersion = ob.checked;
}
onChangeVKeyOn(ob: MatSlideToggleChange) {
// console.log("Viewing key switch is " +
// ( ob.checked ? "[ON]." : "[OFF]." ) );

View File

@ -196,4 +196,8 @@ export class UserService{
return obs;
}
currentOwner() : Owner {
return this.dataStore.owner;
}
}