diff options
| author | Adam Soltys <[email protected]> | 2022-09-29 15:05:13 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-09-29 15:05:13 -0700 |
| commit | 64911388f80d52d6dd53d707457a37fe386c194e (patch) | |
| tree | b96d7c1b85857459d6a91673e5ac6598eed7bd98 /src/routes | |
| parent | 9e07792fcdd0ba0b7c07a20fe83db54597388e26 (diff) | |
| download | coinos-ui-64911388f80d52d6dd53d707457a37fe386c194e.tar.gz coinos-ui-64911388f80d52d6dd53d707457a37fe386c194e.zip | |
address parsing
Diffstat (limited to 'src/routes')
| -rw-r--r-- | src/routes/logout/+page.server.js | 25 | ||||
| -rw-r--r-- | src/routes/scan/+page.svelte | 7 | ||||
| -rw-r--r-- | src/routes/send/+page.svelte | 69 | ||||
| -rw-r--r-- | src/routes/send/bitcoin/[address]/+page.server.js | 8 | ||||
| -rw-r--r-- | src/routes/send/bitcoin/[address]/+page.svelte | 39 | ||||
| -rw-r--r-- | src/routes/send/lightning/+page.svelte | 0 | ||||
| -rw-r--r-- | src/routes/send/lnurl/+page.svelte | 0 |
7 files changed, 97 insertions, 51 deletions
diff --git a/src/routes/logout/+page.server.js b/src/routes/logout/+page.server.js index 3eae005f..726094fd 100644 --- a/src/routes/logout/+page.server.js +++ b/src/routes/logout/+page.server.js @@ -7,19 +7,18 @@ const opts = { path: '/' }; -export async function load({ setHeaders }) { - setHeaders({ - 'set-cookie': [ - cookie.serialize('token', '', { - ...opts, - expires: new Date(0) - }), - cookie.serialize('refresh_token', '', { - ...opts, - expires: new Date(0) - }) - ] - }); +export async function load({ cookies }) { + console.log('COOKIES', cookies); + cookies.set('set-cookie', [ + cookies.serialize('token', '', { + ...opts, + expires: new Date(0) + }), + cookies.serialize('refresh_token', '', { + ...opts, + expires: new Date(0) + }) + ]); throw redirect(302, '/logout/done'); } diff --git a/src/routes/scan/+page.svelte b/src/routes/scan/+page.svelte index 5c8c09f6..9b1072e0 100644 --- a/src/routes/scan/+page.svelte +++ b/src/routes/scan/+page.svelte @@ -2,11 +2,12 @@ import { Icon } from "$comp"; import QrScanner from 'qr-scanner'; import { onMount } from 'svelte'; - import { goBack } from "$lib/utils"; + import { back } from "$lib/utils"; + import { goto } from "$app/navigation"; let scanner, vid; onMount(() => { - scanner = new QrScanner(vid, console.log); + scanner = new QrScanner(vid, (text) => goto(`/send/${text}`)); scanner.start(); }); @@ -14,7 +15,7 @@ <button class="ml-5 md:ml-20 mt-5 md:mt-10 hover:opacity-80" - on:click={goBack} + on:click={back} > <Icon icon="arrow-left" style="w-10" /> </button> diff --git a/src/routes/send/+page.svelte b/src/routes/send/+page.svelte index 777f9766..2162d76d 100644 --- a/src/routes/send/+page.svelte +++ b/src/routes/send/+page.svelte @@ -1,40 +1,32 @@ <script> + import { browser } from '$app/environment'; import { t } from '$lib/translations'; import { AppHeader, Icon, Spinner } from '$comp'; + import { back, focus } from '$lib/utils'; + import parse from '$lib/parse'; - let payreq = '', - loading, - payreqField; + let text, loading; - let withdraw = async () => { - loading = true; - try { - await post('/withdraw', { payreq }); - loading = false; - } catch (e) { - failure(e.message); - loading = false; - } + let paste = async () => { + text = await navigator.clipboard.readText(); }; </script> -<AppHeader avatarPosition="left-[calc(50vw-64px)] lg:left-[calc(15vw-64px)]" /> +<button class="ml-5 md:ml-20 mt-5 md:mt-10 hover:opacity-80" on:click={back}> + <Icon icon="arrow-left" style="w-10" /> +</button> <div class="container px-4 mt-20 max-w-xl mx-auto"> <div> - <!-- found missing translation --> - <label for="invoice" class="font-bold mb-1 block" - >Destination <small class="text-secondary">Address, Invoice, User, Email or Phone</small - ></label - > + <label for="invoice" class="font-bold mb-1 block">Destination</label> - <div class="relative"> + <div class="relative mb-8"> <input - bind:this={payreqField} + placeholder="Address, Invoice, Username" type="text" - name="payreq" + name="text" required - bind:value={payreq} + bind:value={text} class="block rounded-2xl p-3 w-full bg-primary" /> @@ -43,20 +35,27 @@ <Icon icon="scan" style="mr-2 w-6 my-auto" /> </div> </a> + + {#if browser && navigator.clipboard} + <div class="flex absolute h-[48px] right-10 top-0 px-2 mt-[1px]" on:click={paste}> + <Icon icon="paste" style="mr-2 w-6 my-auto" /> + </div> + {/if} </div> </div> - <button - disabled={!payreq} - class="{!payreq - ? 'opacity-50' - : 'opacity-100 hover:opacity-80'} rounded-2xl border py-3 font-bold w-full mt-2 bg-black text-white" - on:click={withdraw} - > - {#if loading} - <Spinner /> - {:else} - {$t('user.dashboard.go')} - {/if} - </button> + <div class="flex w-full"> + <button + class="{!text + ? 'opacity-50' + : '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={() => parse(text)} + > + {#if loading} + <Spinner /> + {:else} + {$t('user.dashboard.go')} + {/if} + </button> + </div> </div> diff --git a/src/routes/send/bitcoin/[address]/+page.server.js b/src/routes/send/bitcoin/[address]/+page.server.js new file mode 100644 index 00000000..8cdf7276 --- /dev/null +++ b/src/routes/send/bitcoin/[address]/+page.server.js @@ -0,0 +1,8 @@ +import { redirect } from "@sveltejs/kit"; +export const actions = { + default: async ({ request }) => { + let form = Object.fromEntries(await request.formData()); + console.log('send bitcoin', form); + throw redirect(307, '/'); + } +}; diff --git a/src/routes/send/bitcoin/[address]/+page.svelte b/src/routes/send/bitcoin/[address]/+page.svelte new file mode 100644 index 00000000..fd635fd5 --- /dev/null +++ b/src/routes/send/bitcoin/[address]/+page.svelte @@ -0,0 +1,39 @@ +<script> + import { AppHeader, Icon, Numpad } from '$comp'; + import { page } from '$app/stores'; + import { back } from '$lib/utils'; + export let data; + + let { address } = $page.params; + let { currency } = data.user; + let amount, loading; +</script> + +<button class="ml-5 md:ml-20 mt-5 md:mt-10 hover:opacity-80" on:click={back}> + <Icon icon="arrow-left" style="w-10" /> +</button> + +<div class="container px-4 mt-20 max-w-xl mx-auto"> + <div class="text-center mb-8"> + <h1 class="text-3xl md:text-4xl font-semibold mb-2">Send to</h1> + <p class="text-lg text-secondary">{address}</p> + </div> + <Numpad bind:amount {currency} /> + + <form method="POST"> + <input name="address" value={address} type="hidden" /> + <input name="amount" value={amount} type="hidden" /> + <div class="flex w-full"> + <button + type="submit" + 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" + > + {#if loading} + <Spinner /> + {:else} + Send + {/if} + </button> + </div> + </form> +</div> diff --git a/src/routes/send/lightning/+page.svelte b/src/routes/send/lightning/+page.svelte new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/src/routes/send/lightning/+page.svelte diff --git a/src/routes/send/lnurl/+page.svelte b/src/routes/send/lnurl/+page.svelte new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/src/routes/send/lnurl/+page.svelte |
