diff options
Diffstat (limited to 'src/routes/(app)/send')
| -rw-r--r-- | src/routes/(app)/send/[...text]/+page.server.js | 4 | ||||
| -rw-r--r-- | src/routes/(app)/send/invoice/[id]/+page.svelte | 54 | ||||
| -rw-r--r-- | src/routes/(app)/send/user/[username]/[...amount]/+page.svelte | 12 |
3 files changed, 45 insertions, 25 deletions
diff --git a/src/routes/(app)/send/[...text]/+page.server.js b/src/routes/(app)/send/[...text]/+page.server.js index ff014315..cafce7c9 100644 --- a/src/routes/(app)/send/[...text]/+page.server.js +++ b/src/routes/(app)/send/[...text]/+page.server.js @@ -41,9 +41,7 @@ let parse = async (t, host) => { ({ id } = await get(`/invoice/${t}`)); } catch (e) { throw redirect(307, `/send/lightning/${t}`); - } - - if (id) throw redirect(307, `/send/${id}`); + } } // bitcoin diff --git a/src/routes/(app)/send/invoice/[id]/+page.svelte b/src/routes/(app)/send/invoice/[id]/+page.svelte index 81ae0e97..554eef6f 100644 --- a/src/routes/(app)/send/invoice/[id]/+page.svelte +++ b/src/routes/(app)/send/invoice/[id]/+page.svelte @@ -1,16 +1,16 @@ <script> import { onDestroy, onMount } from 'svelte'; import { t } from '$lib/translations'; - import { goto } from '$app/navigation'; + import { goto, invalidateAll } from '$app/navigation'; import { pin } from '$lib/store'; import { enhance } from '$app/forms'; import { Avatar, Icon, Numpad, Spinner } from '$comp'; import { page } from '$app/stores'; - import { back, f, fiat as toFiat, s, sats } from '$lib/utils'; + import { post, back, f, fiat as toFiat, s, sats } from '$lib/utils'; export let data; export let form; - let { address, rate, payreq, recipient, tip, rates, user } = data; + let { address, hash, rate, payreq, recipient, tip, rates, user } = data; let { currency } = user; let amount = form?.amount || data.amount; @@ -27,6 +27,15 @@ let loading; let submit = () => (loading = true); + let external = async () => { + let invoice = { type: 'lightning', amount }; + let { hash } = await post(`/${recipient.username}/invoice`, { + invoice + }); + + goto(`/${recipient.username}/invoice/${hash}`, { invalidateAll: true }); + }; + $: rate = data.rate * (rates[user.currency] / rates[data.currency]); $: update(form); @@ -35,24 +44,24 @@ loading = false; }; - onMount(async () => { - if (browser && window.NDEFReader) { - try { - let ndef = new NDEFReader(); - await ndef.scan(); - - ndef.addEventListener('readingerror', (e) => { - console.log('nfc error', e); - }); - - ndef.addEventListener('reading', ({ message, serialNumber }) => { - console.log(message, serialNumber); - }); - } catch (e) { - console.log('NFC error', e); - } - } - }); + // onMount(async () => { + // if (browser && window.NDEFReader) { + // try { + // let ndef = new NDEFReader(); + // await ndef.scan(); + // + // ndef.addEventListener('readingerror', (e) => { + // console.log('nfc error', e); + // }); + // + // ndef.addEventListener('reading', ({ message, serialNumber }) => { + // console.log(message, serialNumber); + // }); + // } catch (e) { + // console.log('NFC error', e); + // } + // } + // }); </script> <button class="ml-5 md:ml-20 mt-5 md:mt-10 hover:opacity-80" on:click={back}> @@ -130,4 +139,7 @@ {/if} </div> </form> + <div class="flex my-20"> + <button class="mx-auto" on:click={external}>{$t('payments.moreOptions')}</button> + </div> </div> diff --git a/src/routes/(app)/send/user/[username]/[...amount]/+page.svelte b/src/routes/(app)/send/user/[username]/[...amount]/+page.svelte index 9ce82d2e..32a13939 100644 --- a/src/routes/(app)/send/user/[username]/[...amount]/+page.svelte +++ b/src/routes/(app)/send/user/[username]/[...amount]/+page.svelte @@ -12,6 +12,7 @@ let { subject, rate, rates, user } = data; let currency = user.currency || subject.currency || 'USD'; + let next; let amount = form?.amount || data.amount; let a, @@ -59,7 +60,14 @@ {/if} <div class="container px-4 mt-20 max-w-xl mx-auto space-y-8"> - <Numpad bind:amount={a} bind:amountFiat={af} {currency} bind:fiat bind:rate={r} /> + <Numpad + bind:amount={a} + bind:amountFiat={af} + {currency} + bind:fiat + bind:rate={r} + bind:submit={next} + /> <form method="POST" use:enhance on:submit={submit}> <input name="amount" value={amount} type="hidden" /> @@ -82,8 +90,10 @@ {:else} <button type="button" + bind:this={next} class="opacity-100 hover:opacity-80'} rounded-2xl border py-3 font-bold mx-auto mt-2 bg-black text-white px-4 w-24" on:click={setAmount} + on:keydown={setAmount} > Next </button> |
