Skip to content

Commit 22bbede

Browse files
author
Matthias Prost
authored
fix(billing): fixed current consumption + home page billing requests order (#19)
1 parent fb415f5 commit 22bbede

File tree

5 files changed

+26
-33
lines changed

5 files changed

+26
-33
lines changed

ios/App/App.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@
347347
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
348348
CODE_SIGN_IDENTITY = "Apple Development";
349349
CODE_SIGN_STYLE = Automatic;
350-
CURRENT_PROJECT_VERSION = 1;
350+
CURRENT_PROJECT_VERSION = 2;
351351
DEVELOPMENT_TEAM = 8754A6XKT5;
352352
INFOPLIST_FILE = App/Info.plist;
353353
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
@@ -370,7 +370,7 @@
370370
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
371371
CODE_SIGN_IDENTITY = "Apple Development";
372372
CODE_SIGN_STYLE = Automatic;
373-
CURRENT_PROJECT_VERSION = 1;
373+
CURRENT_PROJECT_VERSION = 2;
374374
DEVELOPMENT_TEAM = 8754A6XKT5;
375375
INFOPLIST_FILE = App/Info.plist;
376376
IPHONEOS_DEPLOYMENT_TARGET = 11.0;

src/app/pages/billing/billing.page.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@
1919
<ion-item-group>
2020
<ion-item-divider class="title" color="secondary">
2121
<div style="width: 100%">
22-
<div style="float: left">Current Invoice</div>
22+
<div style="float: left">Current Consumption</div>
2323
<div class="last-update">
24-
Updated at <br />{{ currentInvoice.last_update | date:'h:mm a,
25-
dd/MM/yy' }}
24+
Updated at <br />{{ currentInvoice.last_update | date:'h:mm a, dd/MM/yy' }}
2625
</div>
2726
</div>
2827
</ion-item-divider>
@@ -50,7 +49,7 @@
5049

5150
<ion-item-group>
5251
<ion-item-divider class="title" color="secondary"
53-
>Older Invoices</ion-item-divider
52+
>Past Invoices</ion-item-divider
5453
>
5554
<ion-item *ngFor="let billing of billings" lines="full">
5655
<div class="information-title">
@@ -72,7 +71,7 @@
7271
</div>
7372
<div
7473
class="not-found ion-text-center ion-margin-top"
75-
*ngIf="billings && billings.length === 0"
74+
*ngIf="billings && billings.length === 0 && !isLoading"
7675
>
7776
<img alt="no_server" src="../../../../assets/img/invoice.svg" />
7877
<p>No invoice available</p>
Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,31 @@
1-
import { Component } from "@angular/core";
2-
import { Plugins, StatusBarStyle } from "@capacitor/core";
1+
import {Component} from '@angular/core';
2+
import {Plugins, StatusBarStyle} from '@capacitor/core';
33

4-
import { BillingDto } from "../../services/billing/billing.dto";
5-
import { BillingService } from "../../services/billing/billing.service";
4+
import {BillingDto} from '../../services/billing/billing.dto';
5+
import {BillingService} from '../../services/billing/billing.service';
66

7-
const { StatusBar } = Plugins;
7+
const {StatusBar} = Plugins;
88

99
@Component({
10-
selector: "app-billing",
11-
templateUrl: "./billing.page.html",
12-
styleUrls: ["./billing.page.scss"],
10+
selector: 'app-billing',
11+
templateUrl: './billing.page.html',
12+
styleUrls: ['./billing.page.scss'],
1313
})
1414
export class BillingPage {
15-
public billings: BillingDto[];
15+
public billings: BillingDto[] = [];
1616
public currentInvoice: BillingDto;
1717
public isLoading = true;
1818
public billingError = false;
1919

20-
constructor(private billingService: BillingService) {}
20+
constructor(private billingService: BillingService) {
21+
}
2122

2223
ionViewDidEnter(): void {
23-
StatusBar.setStyle({ style: StatusBarStyle.Light });
24+
StatusBar.setStyle({style: StatusBarStyle.Light});
2425
this.refresh()
25-
.then(() => {
26-
this.isLoading = false;
27-
})
2826
.catch(() => {
29-
this.isLoading = false;
3027
this.billingError = true;
31-
});
28+
}).finally(() => this.isLoading = false);
3229
}
3330

3431
public doRefresh(refresher) {
@@ -43,8 +40,9 @@ export class BillingPage {
4340
}
4441

4542
private async refresh(): Promise<any> {
46-
this.billings = await this.billingService.getBillingList(100)
47-
this.billings = this.billings.slice(1, this.billings.length);
48-
this.currentInvoice = this.billings[0];
43+
const billings = await this.billingService.getBillingList(100);
44+
this.currentInvoice = billings[0];
45+
this.billings = billings.slice(1, billings.length);
46+
console.log(this.billings)
4947
}
5048
}

src/app/pages/home/home.page.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export class HomePage {
7575
public async refreshBilling(): Promise<any> {
7676
try {
7777
this.billings = await this.billingService.getBillingList(6);
78+
this.billingError = false;
7879
} catch (e) {
7980
this.billingError = true;
8081

@@ -109,7 +110,8 @@ export class HomePage {
109110
}
110111

111112
public async refresh(): Promise<any> {
112-
await Promise.all([this.refreshBilling(), this.refreshServers()])
113+
await this.refreshServers()
114+
await this.refreshBilling()
113115
}
114116

115117
private async autoRefresh() {

src/app/services/billing/billing.service.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@ import { BillingDto } from "./billing.dto";
1111
export class BillingService {
1212
constructor(private api: ApiService, private storage: Storage) {}
1313

14-
public getAllBilling(): Promise<BillingDto> {
15-
const ApiUrl = this.api.getBillingApiUrl();
16-
17-
return this.api.get<BillingDto>(`${ApiUrl}/invoices`)
18-
}
19-
2014
public async getBillingList(value: number): Promise<any> {
2115
const ApiUrl = this.api.getBillingApiUrl();
2216

0 commit comments

Comments
 (0)