From b1f81daaab3b04e8ae0b3e4edd4984aeade8098e Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 25 Oct 2022 00:11:35 -0700 Subject: send pin --- .../send/user/[username]/[...amount]/+page.server.js | 15 ++++++++++----- src/routes/send/user/[username]/[...amount]/+page.svelte | 16 +++++++++++++++- 2 files changed, 25 insertions(+), 6 deletions(-) (limited to 'src/routes/send/user') diff --git a/src/routes/send/user/[username]/[...amount]/+page.server.js b/src/routes/send/user/[username]/[...amount]/+page.server.js index 12bae186..a659eef3 100644 --- a/src/routes/send/user/[username]/[...amount]/+page.server.js +++ b/src/routes/send/user/[username]/[...amount]/+page.server.js @@ -11,14 +11,19 @@ export async function load({ params, parent }) { export const actions = { default: async ({ cookies, request }) => { - let body = Object.fromEntries(await request.formData()); - let { amount, confirmed } = body; + try { + let body = Object.fromEntries(await request.formData()); + let { amount, confirmed } = body; - if (!confirmed) { - return invalid(403, { amount, confirm: true }); + if (!confirmed) { + return invalid(403, { amount, confirm: true }); + } + + await post('/send', body, auth(cookies)); + } catch (e) { + return invalid(400, { message: e.message }); } - await post('/send', body, auth(cookies)); throw redirect(307, '/sent'); } }; diff --git a/src/routes/send/user/[username]/[...amount]/+page.svelte b/src/routes/send/user/[username]/[...amount]/+page.svelte index e50acd5b..6f4cb313 100644 --- a/src/routes/send/user/[username]/[...amount]/+page.svelte +++ b/src/routes/send/user/[username]/[...amount]/+page.svelte @@ -1,10 +1,11 @@ +{#if form?.message} +
+ {form.message} +
+{/if} +
{#if amount}
@@ -63,6 +76,7 @@ +
{#if amount} -- cgit v1.2.3