diff options
| author | Adam Soltys <[email protected]> | 2023-02-07 11:16:14 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-02-07 11:16:14 -0800 |
| commit | 3626a2388acf8ef213e15ac55a5bcd26ffc93581 (patch) | |
| tree | 0d4b72bc43ec512cd4a53df2dc537b1034010270 | |
| parent | b5b7fe81ba245f85ecc1a67318eeb92a34949861 (diff) | |
| download | coinos-ui-3626a2388acf8ef213e15ac55a5bcd26ffc93581.tar.gz coinos-ui-3626a2388acf8ef213e15ac55a5bcd26ffc93581.zip | |
prompt for pot creation
| -rw-r--r-- | src/components/Pin.svelte | 2 | ||||
| -rw-r--r-- | src/routes/(app)/send/[...text]/+page.server.js | 11 | ||||
| -rw-r--r-- | src/routes/(app)/send/[...text]/+page.svelte | 9 |
3 files changed, 16 insertions, 6 deletions
diff --git a/src/components/Pin.svelte b/src/components/Pin.svelte index 0db831ff..a59f574e 100644 --- a/src/components/Pin.svelte +++ b/src/components/Pin.svelte @@ -10,7 +10,7 @@ let pin = ''; $: update(value); - let update = (v) => (pin = v) || console.log('updated', v, pin); + let update = (v) => (pin = v) $: pin.toString().length > 5 && (value = pin.toString()); </script> diff --git a/src/routes/(app)/send/[...text]/+page.server.js b/src/routes/(app)/send/[...text]/+page.server.js index 3d25ed7e..c64361ff 100644 --- a/src/routes/(app)/send/[...text]/+page.server.js +++ b/src/routes/(app)/send/[...text]/+page.server.js @@ -1,7 +1,7 @@ import { validate } from 'bitcoin-address-validation'; import bip21 from 'bip21'; import { auth, get, post } from '$lib/utils'; -import { redirect } from '@sveltejs/kit'; +import { fail, redirect } from '@sveltejs/kit'; let parse = async (t, host) => { if (!t) return; @@ -61,6 +61,13 @@ let parse = async (t, host) => { } catch (e) {} if (user) throw redirect(307, `/send/user/${t}`); + + let pot; + try { + pot = await get(`/pot/${t}`); + } catch (e) {} + + if (pot) throw redirect(307, `/send/pot/${t}`); }; export async function load({ cookies, params, request, url }) { @@ -75,6 +82,6 @@ export const actions = { const form = await request.formData(); let t = form.get('text'); await parse(t, url.host); - throw redirect(307, `/send/pot/${t}`); + return fail(400, { error: true }); } }; diff --git a/src/routes/(app)/send/[...text]/+page.svelte b/src/routes/(app)/send/[...text]/+page.svelte index cd83ddfc..2a9df12a 100644 --- a/src/routes/(app)/send/[...text]/+page.svelte +++ b/src/routes/(app)/send/[...text]/+page.svelte @@ -37,8 +37,11 @@ <form method="POST" use:enhance> {#if form?.error} - <div class="text-red-600 text-center" in:fly> - {form.error} + <div class="mb-5"> + <div class="text-secondary">Could not find anything with that name. Would you like to create a new pot?</div> + <div class="w-full flex justify-center"> + <a href={`/send/pot/${text}`}><button class="bg-black text-white border rounded-full px-6 py-2 font-bold">Yes</button></a> + </div> </div> {/if} <div class="mb-2"> @@ -90,7 +93,7 @@ <h1 class="px-3 md:px-0 text-xl font-semibold mt-10">{$t('user.send.contacts')}</h1> <div> {#each contacts as c} - <a href={`/send/${c.username}`}> + <a href={`/send/${c.username}`}> <div class="border-b p-2 last:border-b-0 hover:bg-gray-100"> <div class="flex"> <div> |
