diff options
| author | Adam Soltys <[email protected]> | 2024-05-17 09:23:39 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-05-17 09:23:39 -0700 |
| commit | a455c9ff55831264149badb1b5f99d0e9be2c79b (patch) | |
| tree | 08d4d16aa449a42cd25bc78b7e7962d71d7e5164 /src | |
| parent | 7c8cbe1c0b41d223e20823e2896230575a46bad9 (diff) | |
| download | coinos-ui-a455c9ff55831264149badb1b5f99d0e9be2c79b.tar.gz coinos-ui-a455c9ff55831264149badb1b5f99d0e9be2c79b.zip | |
updates from master
Diffstat (limited to 'src')
| -rw-r--r-- | src/routes/(app)/send/[...text]/+page.server.js | 16 | ||||
| -rw-r--r-- | src/routes/(app)/send/[...text]/+page.svelte | 87 |
2 files changed, 34 insertions, 69 deletions
diff --git a/src/routes/(app)/send/[...text]/+page.server.js b/src/routes/(app)/send/[...text]/+page.server.js index 73a44512..3e8623eb 100644 --- a/src/routes/(app)/send/[...text]/+page.server.js +++ b/src/routes/(app)/send/[...text]/+page.server.js @@ -19,6 +19,7 @@ let parse = async (t, host) => { options: { amount }, } = bip21.decode(t)); + if (t.startsWith("lightning:")) t = t.replace("lightning:", ""); if (t.endsWith(`@${PUBLIC_DOMAIN}`)) t = t.split("@")[0]; if (t.includes("@") && t.includes(".")) { try { @@ -26,17 +27,14 @@ let parse = async (t, host) => { } catch (e) {} } - if (t.endsWith("@classic")) { - ({ uuid: id } = await get(`/invoice/classic/${t.replace("@classic", "")}`)); - if (id) redirect(307, `/send/invoice/${id}`); - } - if (t.includes("/fund")) redirect(307, t.substring(t.indexOf("/fund"))); + // lightning + if (t.toLowerCase().startsWith("lightning:")) + t = t.toLowerCase().replace("lightning:", ""); if (t.toLowerCase().startsWith("lnurl")) redirect(307, `/ln/${t}`); if (t.includes(":")) t = t.split(":")[1]; - // lightning if (t.toLowerCase().startsWith("ln")) { try { ({ id } = await get(`/invoice/${t}`)); @@ -55,7 +53,7 @@ let parse = async (t, host) => { redirect(307, r); } - if (user) redirect(307, `/send/${user.username}`); + if (user) redirect(307, `/pay/${user.username}`); else if (id) redirect(307, `/send/${id}`); } @@ -65,7 +63,7 @@ let parse = async (t, host) => { if (user.anon) user = null; } catch (e) {} - if (user) redirect(307, `/send/user/${t}`); + if (user) redirect(307, `/pay/${t}`); let fund; try { @@ -80,7 +78,7 @@ let parse = async (t, host) => { invoice = await get(`/invoice/${t}`); } catch (e) {} - if (invoice) redirect(307, `/send/invoice/${invoice.hash}`); + if (invoice) redirect(307, `/send/invoice/${invoice.id}`); }; export async function load({ cookies, params, request, url }) { diff --git a/src/routes/(app)/send/[...text]/+page.svelte b/src/routes/(app)/send/[...text]/+page.svelte index 2622feed..f9267105 100644 --- a/src/routes/(app)/send/[...text]/+page.svelte +++ b/src/routes/(app)/send/[...text]/+page.svelte @@ -9,7 +9,7 @@ import Avatar from "$comp/Avatar.svelte"; import Icon from "$comp/Icon.svelte"; import Spinner from "$comp/Spinner.svelte"; - import { back, fail } from "$lib/utils"; + import { back, fail, focus } from "$lib/utils"; export let data; export let form; @@ -18,10 +18,8 @@ let { contacts } = data; let w; - let el, textarea, text; - let placeholder = $t("user.send.placeholder"); + let el, text; - $: $page && setTimeout(() => w > 800 && textarea?.focus(), 0); let keypress = (e) => e.key === "Enter" && (e.preventDefault() || el.click()); let paste = async () => { @@ -32,12 +30,12 @@ <svelte:window bind:innerWidth={w} /> <AppHeader {data} /> -<div class="container px-4 max-w-xl mx-auto space-y-7 mt-24"> - <h1 class="px-3 md:px-0 text-center text-4xl md:text-5xl font-semibold font-bebasNeue tracking-[0.2rem]"> +<div class="container px-4 max-w-lg mx-auto space-y-5 mt-20"> + <h1 class="px-3 md:px-0 text-center text-3xl md:text-4xl font-semibold"> {$t("payments.send")} </h1> - <form method="POST" use:enhance> + <form method="POST" use:enhance class="space-y-2 text-xl"> {#if form?.error} <div class="mb-5"> <div class="text-red-600"> @@ -46,89 +44,58 @@ </div> {/if} - <div class="mb-4"> - <input type="hidden" name="text" bind:value={text} /> - + <div class="mb-2"> <textarea - {placeholder} + use:focus + name="text" + placeholder={$t("user.send.placeholder")} on:keypress={keypress} - class="w-full p-4 border border-stone-400 focus:outline-none focus:ring-2 hover:ring-2 ring-stone-900 dark:ring-white transition-all duration-500 rounded-xl h-48 dark:bg-stone-800 placeholder:text-stone-300" + class="w-full p-4 border rounded-xl h-48 text-xl" bind:value={text} - bind:this={textarea} + autocapitalize="none" /> </div> - <div class="grid grid-cols-2 md:grid-cols-4 gap-3"> - <a - href={`/qr/${encodeURIComponent(text)}`} - class:invisible={!text?.length} - > - <button - type="button" - class="flex border dark:border-white rounded-full px-6 py-2 font-bold hover:opacity-80 mr-1 w-full" - > - <Icon icon="qr" style="mr-2 w-6 my-auto invert dark:invert-0" /> - <div class="my-auto">{$t("user.send.makeQR")}</div> - </button> - </a> - + <div class="flex gap-2"> <a href="/scan" class="w-full"> <button type="button" - class="flex border dark:border-white rounded-full px-6 py-2 font-bold hover:opacity-80 mr-1 w-full" + class="flex border rounded-2xl px-6 py-5 font-bold hover:opacity-80 w-full bg-primary justify-center" > - <Icon icon="camera" style="mr-2 w-6 my-auto dark:invert" /> + <Icon icon="camera" style="mr-2 w-6 my-auto" /> <div class="my-auto">{$t("user.send.scan")}</div> </button> </a> <button type="button" - class="flex border dark:border-white rounded-full px-6 py-2 font-bold hover:opacity-80 " + class="flex border rounded-2xl px-6 py-5 font-bold hover:opacity-80 w-full bg-primary justify-center" on:click={paste} > - <Icon icon="paste" style="mr-2 w-6 my-auto dark:invert" /> + <Icon icon="paste" style="mr-2 w-6 my-auto" /> <div class="my-auto">{$t("user.send.paste")}</div> </button> - - <button - bind:this={el} - type="submit" - class="{!text - ? 'opacity-50' - : 'opacity-100 hover:opacity-80'} bg-black dark:bg-swapee-purple text-white border rounded-full px-6 py-2 font-bold" - > - {$t("user.send.next")} - </button> </div> + + <button + bind:this={el} + type="submit" + class="bg-black text-white border rounded-2xl px-6 py-5 w-full font-bold" + > + {$t("user.send.next")} + </button> </form> {#if contacts.length} <div class="space-y-5"> - <h1 class="px-3 md:px-0 text-xl font-semibold mt-10"> + <h1 class="px-3 md:px-0 text-2xl font-semibold mt-10"> {$t("user.send.contacts")} </h1> <div> - <!-- <a href={`/send/$aaaa`}> - <div - class="border-b p-2 last:border-b-0 hover:bg-gray-200 dark:hover:bg-swapee-purple transition-all duration-200 ease-out rounded-2xl hover:ring-1 ring-swapee-purple" - > - <div class="flex"> - <div> - <div class="flex"> - <Avatar size={20} disabled={true} /> - <div class="my-auto text-left"> - <p class="ml-1 text-lg break-words">aaa aasa</p> - </div> - </div> - </div> - </div> - </div> - </a> --> {#each contacts as c} - <a href={`/send/${c.username}`}> + <a href={`/pay/${c.username}`}> <div - class="border-b p-2 last:border-b-0 hover:bg-gray-200 dark:hover:bg-stone-800 transition-all duration-200 ease-out rounded-2xl" + class="border-b p-2 last:border-b-0 hover:bg-gray-100 rounded-2xl" > <div class="flex"> <div> |
