aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/send/fund
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-11-08 13:46:04 -0800
committerAdam Soltys <[email protected]>2023-11-11 00:04:22 -0800
commit8041f705373758940b9487ed5c4cd34bfb04ac16 (patch)
treea96ded4f227e157762d446e8d946a94cae861b0d /src/routes/(app)/send/fund
parent84022507dd5d5a03aedb986f0ff28c81a3bcaeec (diff)
downloadcoinos-ui-8041f705373758940b9487ed5c4cd34bfb04ac16.tar.gz
coinos-ui-8041f705373758940b9487ed5c4cd34bfb04ac16.zip
rename pot to fund
Diffstat (limited to 'src/routes/(app)/send/fund')
-rw-r--r--src/routes/(app)/send/fund/[name]/[...amount]/+page.server.js17
-rw-r--r--src/routes/(app)/send/fund/[name]/[...amount]/+page.svelte58
2 files changed, 75 insertions, 0 deletions
diff --git a/src/routes/(app)/send/fund/[name]/[...amount]/+page.server.js b/src/routes/(app)/send/fund/[name]/[...amount]/+page.server.js
new file mode 100644
index 00000000..2cb3c4a9
--- /dev/null
+++ b/src/routes/(app)/send/fund/[name]/[...amount]/+page.server.js
@@ -0,0 +1,17 @@
+import { fail, redirect } from '@sveltejs/kit';
+import { auth, fd, post } from '$lib/utils';
+
+export const actions = {
+ default: async ({ cookies, request }) => {
+ let body = await fd(request);
+ let p;
+
+ try {
+ p = await post('/payments', body, auth(cookies));
+ } catch (e) {
+ return fail(400, { message: e.message });
+ }
+
+ if (p) throw redirect(307, `/fund/${body.name}`);
+ }
+};
diff --git a/src/routes/(app)/send/fund/[name]/[...amount]/+page.svelte b/src/routes/(app)/send/fund/[name]/[...amount]/+page.svelte
new file mode 100644
index 00000000..6aecf8f3
--- /dev/null
+++ b/src/routes/(app)/send/fund/[name]/[...amount]/+page.svelte
@@ -0,0 +1,58 @@
+<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 { rates } = data;
+ let { currency } = data.user;
+ let loading;
+
+ $: rate = rates[currency];
+
+ 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} bind:rate />
+
+ <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>