From b972aa21389c20ab9da1a627612bbc1dafeec366 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 29 Jul 2022 23:40:59 -0700 Subject: dynamic qr lib import and invoice amount param --- src/routes/invoice/[amount].js | 14 +++ src/routes/invoice/[amount].svelte | 252 +++++++++++++++++++++++++++++++++++++ 2 files changed, 266 insertions(+) create mode 100644 src/routes/invoice/[amount].js create mode 100644 src/routes/invoice/[amount].svelte (limited to 'src/routes/invoice') diff --git a/src/routes/invoice/[amount].js b/src/routes/invoice/[amount].js new file mode 100644 index 00000000..f75a1672 --- /dev/null +++ b/src/routes/invoice/[amount].js @@ -0,0 +1,14 @@ +import { post } from '$lib/utils'; + +const username = 'bob', + network = 'lightning'; + +export async function GET({ params }) { + let { amount } = params; + console.log("AMT", amount); + let { text } = await post('/lightning/invoice', { amount }); + console.log("TXT", text); + await post('/invoice', { invoice: { text, network }, user: { username } }); + + return { body: { amount, text } }; +} diff --git a/src/routes/invoice/[amount].svelte b/src/routes/invoice/[amount].svelte new file mode 100644 index 00000000..dd6ed7fa --- /dev/null +++ b/src/routes/invoice/[amount].svelte @@ -0,0 +1,252 @@ + + + + +
+
+ {#if $invoiceAmount && $invoiceAmountFiat && $rate && text} + +
+

Add a tip?

+ +
+ {tipAmountFormatted}{`(${tipAmountSats} SATS)`} + {tipPercent}% +
+ + { + customTipAmount = ''; + tipPercent = e.target.value; + }} + /> + +
+ {#each tipAmounts as amount} + + {/each} + +
+ $ + handleCustomTipAmount(e)} + class="bg-primary rounded-2xl py-3 px-10 font-semibold mt-2 mr-1 w-full md:w-auto" + placeholder="Other" + /> + +
+
+
+ +
+ + +
+ Scan to pay insert name here + +
+ +
+
+ Invoice + {invoiceAmountFiatFormatted} + {`(${invoiceAmountFormatted} SATS)`} +
+ +
+ Tip + {tipAmountFormatted} + {`(${tipAmountSats} SATS)`} +
+ +
+ Total + {totalAmountFormatted} + {`(${totalAmountSats} SATS)`} +
+
+
+ {:else} +
+
+
+ {/if} +
+
+ + -- cgit v1.2.3 From 8b0d28fecb0e38ac9c85e5e3e7edecc857773f51 Mon Sep 17 00:00:00 2001 From: secondl1ght <85003930+secondl1ght@users.noreply.github.com> Date: Sat, 30 Jul 2022 00:41:39 -0600 Subject: format --- src/routes/invoice/[amount].js | 6 +++--- src/routes/invoice/[amount].svelte | 4 ++-- src/routes/receive.svelte | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/routes/invoice') diff --git a/src/routes/invoice/[amount].js b/src/routes/invoice/[amount].js index f75a1672..f9b31211 100644 --- a/src/routes/invoice/[amount].js +++ b/src/routes/invoice/[amount].js @@ -4,10 +4,10 @@ const username = 'bob', network = 'lightning'; export async function GET({ params }) { - let { amount } = params; - console.log("AMT", amount); + let { amount } = params; + console.log('AMT', amount); let { text } = await post('/lightning/invoice', { amount }); - console.log("TXT", text); + console.log('TXT', text); await post('/invoice', { invoice: { text, network }, user: { username } }); return { body: { amount, text } }; diff --git a/src/routes/invoice/[amount].svelte b/src/routes/invoice/[amount].svelte index dd6ed7fa..4c1ec199 100644 --- a/src/routes/invoice/[amount].svelte +++ b/src/routes/invoice/[amount].svelte @@ -6,7 +6,7 @@ import { onMount } from 'svelte'; export let text; - export let amount; + export let amount; let tipPercent = 0; const setRate = ($invoiceAmountFiat / $invoiceAmount) * 100000000; @@ -64,7 +64,7 @@ onMount(async () => { if (browser) { - let { default: QRCodeStyling } = await import('qr-code-styling'); + let { default: QRCodeStyling } = await import('qr-code-styling'); const qrCode = new QRCodeStyling({ width: window.screen.width < 640 ? 250 : 300, type: 'svg', diff --git a/src/routes/receive.svelte b/src/routes/receive.svelte index ff156783..e78934a9 100644 --- a/src/routes/receive.svelte +++ b/src/routes/receive.svelte @@ -160,7 +160,7 @@ 0 ? 'opacity-50' : 'opacity-100'}" - on:click={() => goto(`/invoice/${$invoiceAmount}`)} + on:click={() => goto(`/invoice/${$invoiceAmount}`)} disabled={$invoiceAmount === 0}> Show QR + import { Icon } from '$comp'; + + +
+
+ + + + + + +

404

+

Page not found.

+
+
diff --git a/src/routes/__error.svelte b/src/routes/__error.svelte new file mode 100644 index 00000000..6cdeeac7 --- /dev/null +++ b/src/routes/__error.svelte @@ -0,0 +1,16 @@ + + +
+
+ + + + + + +

Error

+

Please try again or contact support.

+
+
diff --git a/src/routes/invoice/[amount].svelte b/src/routes/invoice/[amount].svelte index 4c1ec199..2cf16e37 100644 --- a/src/routes/invoice/[amount].svelte +++ b/src/routes/invoice/[amount].svelte @@ -8,6 +8,10 @@ export let text; export let amount; + if (!$user && typeof window !== 'undefined') { + window.location = '/login'; + } + let tipPercent = 0; const setRate = ($invoiceAmountFiat / $invoiceAmount) * 100000000; @@ -83,131 +87,133 @@ }); - - -
-
- {#if $invoiceAmount && $invoiceAmountFiat && $rate && text} - -
-

Add a tip?

- -
- {tipAmountFormatted}{`(${tipAmountSats} SATS)`} - {tipPercent}% -
- - { - customTipAmount = ''; - tipPercent = e.target.value; - }} - /> - -
- {#each tipAmounts as amount} - goto('/receive')}> + + + +
+
+ {#if $invoiceAmount && $invoiceAmountFiat && $rate && text} + +
+

Add a tip?

+ +
+ {tipAmountFormatted}{`(${tipAmountSats} SATS)`} - {/each} + {tipPercent}% +
-
- $ - handleCustomTipAmount(e)} - class="bg-primary rounded-2xl py-3 px-10 font-semibold mt-2 mr-1 w-full md:w-auto" - placeholder="Other" - /> - + { + customTipAmount = ''; + tipPercent = e.target.value; + }} + /> + +
+ {#each tipAmounts as amount} + + {/each} + +
+ $ + handleCustomTipAmount(e)} + class="bg-primary rounded-2xl py-3 px-10 font-semibold mt-2 mr-1 w-full md:w-auto" + placeholder="Other" + /> + +
-
- -
- - -
- Scan to pay insert name here
-
-
- Invoice - {invoiceAmountFiatFormatted} - {`(${invoiceAmountFormatted} SATS)`} -
- -
- Tip - {tipAmountFormatted} - {`(${tipAmountSats} SATS)`} -
+ +
+ Scan to pay insert name here -
- Total - {totalAmountFormatted} - {`(${totalAmountSats} SATS)`} +
+ +
+
+ Invoice + {invoiceAmountFiatFormatted} + {`(${invoiceAmountFormatted} SATS)`} +
+ +
+ Tip + {tipAmountFormatted} + {`(${tipAmountSats} SATS)`} +
+ +
+ Total + {totalAmountFormatted} + {`(${totalAmountSats} SATS)`} +
-
- {:else} -
-
-
- {/if} + {:else} +
+
+
+ {/if} +
-
+{/if} diff --git a/static/icons/heart.svg b/static/icons/heart.svg new file mode 100644 index 00000000..f3a5f757 --- /dev/null +++ b/static/icons/heart.svg @@ -0,0 +1,3 @@ + + + -- cgit v1.2.3 From 5bf4891768f1ee359ee5795272c289b40745aed5 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 30 Jul 2022 11:13:39 -0700 Subject: get invoice by uuid --- src/components/AppHeader.svelte | 4 +- src/components/RegisterOrLogin.svelte | 2 +- src/lib/utils.js | 5 + src/routes/[username].js | 3 - src/routes/[username].svelte | 27 --- src/routes/[username]/index.js | 3 + src/routes/[username]/index.svelte | 27 +++ src/routes/[username]/receive.svelte | 188 ++++++++++++++++++++ src/routes/__layout.svelte | 2 +- src/routes/invoice/[amount].js | 12 -- src/routes/invoice/[amount].svelte | 322 ---------------------------------- src/routes/invoice/[id].js | 11 ++ src/routes/invoice/[id].svelte | 322 ++++++++++++++++++++++++++++++++++ src/routes/invoice/index.js | 11 ++ src/routes/receive.svelte | 178 ------------------- 15 files changed, 572 insertions(+), 545 deletions(-) delete mode 100644 src/routes/[username].js delete mode 100644 src/routes/[username].svelte create mode 100644 src/routes/[username]/index.js create mode 100644 src/routes/[username]/index.svelte create mode 100644 src/routes/[username]/receive.svelte delete mode 100644 src/routes/invoice/[amount].js delete mode 100644 src/routes/invoice/[amount].svelte create mode 100644 src/routes/invoice/[id].js create mode 100644 src/routes/invoice/[id].svelte create mode 100644 src/routes/invoice/index.js delete mode 100644 src/routes/receive.svelte (limited to 'src/routes/invoice') diff --git a/src/components/AppHeader.svelte b/src/components/AppHeader.svelte index b096f01e..99eea6d5 100644 --- a/src/components/AppHeader.svelte +++ b/src/components/AppHeader.svelte @@ -8,9 +8,11 @@