aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/send/pot
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-01-18 19:44:27 -0800
committerAdam Soltys <[email protected]>2023-01-18 19:44:27 -0800
commit67c4af186fec0423664b18847921eb9696a1eeef (patch)
tree85e0fb00f3aa89fdde1cbb667bf801564bff7610 /src/routes/(app)/send/pot
parentb1ad12734eeafc36a07bd76f649a98ae9ade5723 (diff)
downloadcoinos-ui-67c4af186fec0423664b18847921eb9696a1eeef.tar.gz
coinos-ui-67c4af186fec0423664b18847921eb9696a1eeef.zip
pots
Diffstat (limited to 'src/routes/(app)/send/pot')
-rw-r--r--src/routes/(app)/send/pot/[name]/[...amount]/+page.server.js17
-rw-r--r--src/routes/(app)/send/pot/[name]/[...amount]/+page.svelte55
2 files changed, 72 insertions, 0 deletions
diff --git a/src/routes/(app)/send/pot/[name]/[...amount]/+page.server.js b/src/routes/(app)/send/pot/[name]/[...amount]/+page.server.js
new file mode 100644
index 00000000..f25fcb6d
--- /dev/null
+++ b/src/routes/(app)/send/pot/[name]/[...amount]/+page.server.js
@@ -0,0 +1,17 @@
+import { invalid, redirect } from '@sveltejs/kit';
+import { auth, post } from '$lib/utils';
+
+export const actions = {
+ default: async ({ cookies, request }) => {
+ let body = Object.fromEntries(await request.formData());
+ let p;
+
+ try {
+ p = await post('/send', body, auth(cookies));
+ } catch (e) {
+ return invalid(400, { message: e.message });
+ }
+
+ if (p) throw redirect(307, `/pot/${body.name}`);
+ }
+};
diff --git a/src/routes/(app)/send/pot/[name]/[...amount]/+page.svelte b/src/routes/(app)/send/pot/[name]/[...amount]/+page.svelte
new file mode 100644
index 00000000..bb11ddde
--- /dev/null
+++ b/src/routes/(app)/send/pot/[name]/[...amount]/+page.svelte
@@ -0,0 +1,55 @@
+<script>
+ import { t } from '$lib/translations';
+ import { enhance } from '$app/forms';
+ import { Icon, Numpad, Spinner } from '$comp';
+ import { page } from '$app/stores';
+ import { back } from '$lib/utils';
+ import { pin } from '$lib/store';
+
+ export let data;
+ export let form;
+
+ let { amount, name } = $page.params;
+ let { currency } = data.user;
+ let loading;
+
+ let submit = () => (loading = true);
+ $: update(form);
+ let update = () => {
+ if (form?.message.includes('pin')) $pin = undefined;
+ loading = false;
+ };
+</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>
+
+{#if form?.message}
+ <div class="text-red-600 text-center">
+ {form.message}
+ </div>
+{/if}
+
+<div class="container px-4 mt-20 max-w-xl mx-auto">
+ <Numpad bind:amount {currency} />
+
+ <form method="POST" use:enhance on:submit={submit}>
+ <input name="name" value={name} type="hidden" />
+ <input name="amount" value={amount} type="hidden" />
+ <input name="pin" value={$pin} 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}
+ {$t('payments.send')}
+ {/if}
+ </button>
+ </div>
+ </form>
+</div>