Fix layout of expire progress bar

This commit is contained in:
2021-02-01 13:06:25 +01:00
parent dfda3e07e0
commit 39659c4373
4 changed files with 24 additions and 6 deletions

View File

@@ -154,6 +154,14 @@ export class BackendService {
}); });
} }
setInvoiceExpired() {
// Don't set expired if status is not pending
if (this.invoice.status !== PaymentStatus.PENDING) { return; }
this.invoice.status = PaymentStatus.TOOLATE;
this.invoiceUpdate.next(this.invoice);
}
/** /**
* This will notify the backend that the user just cancelled the payment. * This will notify the backend that the user just cancelled the payment.
*/ */

View File

@@ -223,10 +223,11 @@
.progress div { .progress div {
vertical-align: middle; vertical-align: middle;
align-items: center; align-items: center;
padding-bottom: .5rem;
} }
.progress div span { .progress div img {
padding-bottom: .5rem; transform: translateY(10px);
} }
.progress div * { .progress div * {

View File

@@ -103,17 +103,26 @@ export class PaymentComponent implements OnInit {
return address; return address;
} }
updateRemainingTime() { updateRemainingTime(): void {
setInterval(() => { setInterval(() => {
const createdAt = new Date(this.backend.invoice.createdAt); const createdAt = new Date(this.backend.invoice.createdAt);
const dueBy = new Date(this.backend.invoice.dueBy); const dueBy = new Date(this.backend.invoice.dueBy);
const timeTotal = Math.abs(dueBy.getTime() - createdAt.getTime()); const timeTotal = Math.abs(dueBy.getTime() - createdAt.getTime());
const timeLeft = Math.abs(dueBy.getTime() - Date.now()); const timeLeft = Math.abs(dueBy.getTime() - Date.now());
const timeLeftDate = new Date(timeLeft); const timeLeftDate = new Date(timeLeft);
const timeLeftFormat = timeLeftDate.getMinutes() + ':' +
(timeLeftDate.getSeconds() < 10 ? '0' + timeLeftDate.getSeconds() : timeLeftDate.getSeconds());
this.progressTime = timeLeft / timeTotal * 1000; this.progressTime = timeLeft / timeTotal * 1000;
this.formatedTime = `${timeLeftDate.getMinutes()}:${timeLeftDate.getSeconds()} left`; this.formatedTime = `${timeLeftFormat} left`;
}, 500);
// Flag invoice as expired in advance
if (timeLeftDate.getMinutes() === 0 && timeLeftDate.getSeconds() === 0) {
this.formatedTime = '00:00 left';
this.backend.setInvoiceExpired();
}
}, 200);
} }
async get(): Promise<void> { async get(): Promise<void> {

View File

@@ -1,4 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-clock" width="32" height="32" viewBox="0 0 24 24" stroke-width="1.5" stroke="#fff" fill="none" stroke-linecap="round" stroke-linejoin="round"> <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-clock" width="28" height="28" viewBox="0 0 24 24" stroke-width="1.5" stroke="#fff" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"/> <path stroke="none" d="M0 0h24v24H0z" fill="none"/>
<circle cx="12" cy="12" r="9" /> <circle cx="12" cy="12" r="9" />
<polyline points="12 7 12 12 15 15" /> <polyline points="12 7 12 12 15 15" />

Before

Width:  |  Height:  |  Size: 355 B

After

Width:  |  Height:  |  Size: 355 B