From 6171bfebde41e66b78aa8869c984a63b6954cec4 Mon Sep 17 00:00:00 2001 From: ekzyis Date: Sun, 3 Dec 2023 00:27:21 +0100 Subject: [PATCH] Improve invoice status * show if invoice expired * refactor style if invoice not found --- vue/src/components/Invoice.vue | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/vue/src/components/Invoice.vue b/vue/src/components/Invoice.vue index 427f3a0..fd5a912 100644 --- a/vue/src/components/Invoice.vue +++ b/vue/src/components/Invoice.vue @@ -3,13 +3,15 @@
Payment Required
- +
Paid
Redirecting in {{ redirectTimeout }} ...
-
-
Error
- {{ error }} +
+
Expired
+
+
+
Not Found
@@ -67,7 +69,7 @@ const route = useRoute() const invoice = ref(undefined) const redirectTimeout = ref(4) -const error = ref(null) +const notFound = ref(undefined) const label = ref('copy') let copyTimeout = null @@ -86,8 +88,8 @@ const INVOICE_POLL = 2000 const fetchInvoice = async () => { const url = window.origin + '/api/invoice/' + route.params.id const res = await fetch(url) + notFound.value = res.status === 404 if (res.status === 404) { - error.value = 'invoice not found' return } const body = await res.json() @@ -103,6 +105,10 @@ const fetchInvoice = async () => { } } invoice.value = body + if (new Date(invoice.value.ExpiresAt) < new Date()) { + // invoice expired + return + } if (!invoice.value.ConfirmedAt) { // invoice not pad (yet?) pollTimeout = setTimeout(() => {