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 - Added new service for Xero integration
### Changed ### 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 - Updated Order and Owner model to include new Xero integration fields
## [1.2.2] - 2022-08-05 ## [1.2.2] - 2022-08-05

View file

@ -44,10 +44,11 @@
<table width="100%"> <table width="100%">
<tr> <tr>
<td> <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>
<td align="center"> <td align="center">
{{order.timestamp | date: 'short'}} {{order.timestamp | date: 'MM/dd/YY, hh:mm a'}}
</td> </td>
</tr> </tr>
</table> </table>

View file

@ -30,7 +30,7 @@ export class ListOrdersComponent implements OnInit, OnDestroy{
public orders: Order[] = []; public orders: Order[] = [];
public ownerUpdate: Observable<Owner>; public ownerUpdate: Observable<Owner>;
public ordersUpdate: Observable<Order[]>; public ordersUpdate: Observable<Order[]>;
// ------------------------------------ // ------------------------------------
// //
@ -40,6 +40,32 @@ export class ListOrdersComponent implements OnInit, OnDestroy{
faCheckCircle = faCheckCircle; faCheckCircle = faCheckCircle;
faHourglass = faHourglass; faHourglass = faHourglass;
faTrash = faTrash; 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(){ 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.ordersUpdate.subscribe((orders) => {
this.total = 0; this.total = 0;
this.todayTotal = 0; this.todayTotal = 0;
var today = new Date(); var today = new Date();
this.orders = orders; this.orders = orders;
console.log(this.ownerUpdate);
for (let i=0; i < this.orders.length; i++){ for (let i=0; i < this.orders.length; i++){
this.total += this.orders[i].totalZec; this.total += this.orders[i].totalZec;
//
var date = new Date(this.orders[i]!.timestamp!); var date = new Date(this.orders[i]!.timestamp!);
var diff = (today.getTime() / 1000) - (date.getTime()/1000); var diff = (today.getTime() / 1000) - (date.getTime()/1000);
if (diff < (24*3600)){ if (diff < (24*3600)){

View file

@ -244,9 +244,16 @@ public order: Order = {
console.log('Invoice type is invalid' ); console.log('Invoice type is invalid' );
this.reportType = 5; this.reportType = 5;
} }
}, error => { },
error => {
console.log("Error while getting invData!!!"); console.log("Error while getting invData!!!");
console.log(error); 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 correctLevel: QRCode.CorrectLevel.H
}); });
}, error => {
console.log(error.message);
}); });
} }

View file

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

View file

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

View file

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