From 23ffc5a6359dbc84a1de1da632412edeb9989b5f Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 2 Nov 2022 19:47:29 -0700 Subject: move to app layout --- src/routes/(app)/invoice/[id]/+layout.server.js | 14 ++ src/routes/(app)/invoice/[id]/+layout.svelte | 1 + src/routes/(app)/invoice/[id]/+page.server.js | 5 + src/routes/(app)/invoice/[id]/+page.svelte | 134 ++++++++++++ src/routes/(app)/invoice/[id]/paid/+page.svelte | 40 ++++ src/routes/(app)/invoice/[id]/tip/+page.server.js | 5 + src/routes/(app)/invoice/[id]/tip/+page.svelte | 251 ++++++++++++++++++++++ 7 files changed, 450 insertions(+) create mode 100644 src/routes/(app)/invoice/[id]/+layout.server.js create mode 100644 src/routes/(app)/invoice/[id]/+layout.svelte create mode 100644 src/routes/(app)/invoice/[id]/+page.server.js create mode 100644 src/routes/(app)/invoice/[id]/+page.svelte create mode 100644 src/routes/(app)/invoice/[id]/paid/+page.svelte create mode 100644 src/routes/(app)/invoice/[id]/tip/+page.server.js create mode 100644 src/routes/(app)/invoice/[id]/tip/+page.svelte (limited to 'src/routes/(app)/invoice') diff --git a/src/routes/(app)/invoice/[id]/+layout.server.js b/src/routes/(app)/invoice/[id]/+layout.server.js new file mode 100644 index 00000000..690deda0 --- /dev/null +++ b/src/routes/(app)/invoice/[id]/+layout.server.js @@ -0,0 +1,14 @@ +import Qr from 'qrcode-svg'; +import { get } from '$lib/utils'; + +export async function load({ params }) { + let { id } = params; + let invoice = await get(`/invoice?uuid=${id}`); + let svg = new Qr({ + content: invoice.text, + join: true, + container: 'svg-viewbox' + }).svg(); + + return { id, invoice, svg }; +} diff --git a/src/routes/(app)/invoice/[id]/+layout.svelte b/src/routes/(app)/invoice/[id]/+layout.svelte new file mode 100644 index 00000000..4fa864ce --- /dev/null +++ b/src/routes/(app)/invoice/[id]/+layout.svelte @@ -0,0 +1 @@ + diff --git a/src/routes/(app)/invoice/[id]/+page.server.js b/src/routes/(app)/invoice/[id]/+page.server.js new file mode 100644 index 00000000..1068f273 --- /dev/null +++ b/src/routes/(app)/invoice/[id]/+page.server.js @@ -0,0 +1,5 @@ +import invoice from '$lib/invoice'; + +export const actions = { + default: invoice +}; diff --git a/src/routes/(app)/invoice/[id]/+page.svelte b/src/routes/(app)/invoice/[id]/+page.svelte new file mode 100644 index 00000000..bb41a116 --- /dev/null +++ b/src/routes/(app)/invoice/[id]/+page.svelte @@ -0,0 +1,134 @@ + + + + +
+
+
+ Scan to pay {username} + +
+
+ {@html svg} +
+
+ +
+ +
+ +
+ {#if invoice.tip} +
+ {$t('invoice.invoice')} + {f(amountFiat, currency)} + {`(${s(amount)} SAT)`} +
+ +
+ {$t('invoice.tip')} + {f(tipAmount, currency)} + {`(${s(tip)} SAT)`} +
+ {/if} + +
+ {$t('invoice.total')} + {f(amountFiat + parseFloat(tipAmount), currency)} + {`(${s(tip + amount)} SAT)`} +
+
+
+
+
+ + diff --git a/src/routes/(app)/invoice/[id]/paid/+page.svelte b/src/routes/(app)/invoice/[id]/paid/+page.svelte new file mode 100644 index 00000000..d619b7ff --- /dev/null +++ b/src/routes/(app)/invoice/[id]/paid/+page.svelte @@ -0,0 +1,40 @@ + + +
+
+ +
+

{$t('invoice.paymentSuccessful')}

+

+ {f(amountFiat, invoice.currency)} +

+

({s(invoice.amount)} SAT)

+ +
diff --git a/src/routes/(app)/invoice/[id]/tip/+page.server.js b/src/routes/(app)/invoice/[id]/tip/+page.server.js new file mode 100644 index 00000000..1068f273 --- /dev/null +++ b/src/routes/(app)/invoice/[id]/tip/+page.server.js @@ -0,0 +1,5 @@ +import invoice from '$lib/invoice'; + +export const actions = { + default: invoice +}; diff --git a/src/routes/(app)/invoice/[id]/tip/+page.svelte b/src/routes/(app)/invoice/[id]/tip/+page.svelte new file mode 100644 index 00000000..6ea3aae5 --- /dev/null +++ b/src/routes/(app)/invoice/[id]/tip/+page.svelte @@ -0,0 +1,251 @@ + + + + +
+
+ + + + + + +

{$t('invoice.addTipq')}

+ {#if !showCustomAmount} +
{Math.round(tipPercent)}%
+ + + +
+
+ + {f(amountFiat, currency)} + +{f(tipAmount, currency)} + +
+ +
+ {s(amount)} + +{s(tip)} SAT +
+
+ + {#if tip} +
+ + +
+ {:else} + {#each tipAmounts as amount} + + {/each} + {/if} + +
+ +
+ {/if} + +
+
+ + {/if} + + + -- cgit v1.2.3