aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes
diff options
context:
space:
mode:
Diffstat (limited to 'src/routes')
-rw-r--r--src/routes/(app)/fund/[id]/withdraw/+page.svelte2
-rw-r--r--src/routes/(app)/pay/[username]/[...amount]/+page.server.ts1
-rw-r--r--src/routes/(app)/send/bitcoin/[address]/+page.server.ts6
-rw-r--r--src/routes/(app)/send/invoice/[id]/+page.server.ts49
-rw-r--r--src/routes/(app)/send/invoice/[id]/+page.svelte4
5 files changed, 32 insertions, 30 deletions
diff --git a/src/routes/(app)/fund/[id]/withdraw/+page.svelte b/src/routes/(app)/fund/[id]/withdraw/+page.svelte
index 7af07e38..0ad3c2cf 100644
--- a/src/routes/(app)/fund/[id]/withdraw/+page.svelte
+++ b/src/routes/(app)/fund/[id]/withdraw/+page.svelte
@@ -37,7 +37,7 @@
{/if}
<div class="container px-4 mt-20 max-w-xl mx-auto">
- <Numpad bind:amount bind:currency bind:rate {submit} />
+ <Numpad bind:amount bind:currency bind:rate />
<form method="POST" use:enhance on:submit={submit}>
<input name="id" value={id} type="hidden" />
diff --git a/src/routes/(app)/pay/[username]/[...amount]/+page.server.ts b/src/routes/(app)/pay/[username]/[...amount]/+page.server.ts
index 60288813..9c8a6927 100644
--- a/src/routes/(app)/pay/[username]/[...amount]/+page.server.ts
+++ b/src/routes/(app)/pay/[username]/[...amount]/+page.server.ts
@@ -12,7 +12,6 @@ export async function load({ cookies, params, parent }) {
let rate;
- console.log("HI", amount);
if (amount) {
rate = rates[currency ? currency.toUpperCase() : subject.currency];
if (!rate) error(500, "Invalid currency symbol");
diff --git a/src/routes/(app)/send/bitcoin/[address]/+page.server.ts b/src/routes/(app)/send/bitcoin/[address]/+page.server.ts
index a9b72787..f27d3fab 100644
--- a/src/routes/(app)/send/bitcoin/[address]/+page.server.ts
+++ b/src/routes/(app)/send/bitcoin/[address]/+page.server.ts
@@ -1,7 +1,7 @@
import { auth, get } from "$lib/utils";
export async function load({ cookies }) {
- let aid = cookies.get("aid");
- let { balance } = await get(`/account/${aid}`, auth(cookies));
- return { balance };
+ const aid = cookies.get("aid");
+ const { balance } = await get(`/account/${aid}`, auth(cookies));
+ return { balance };
}
diff --git a/src/routes/(app)/send/invoice/[id]/+page.server.ts b/src/routes/(app)/send/invoice/[id]/+page.server.ts
index f294f88d..f1c00c0f 100644
--- a/src/routes/(app)/send/invoice/[id]/+page.server.ts
+++ b/src/routes/(app)/send/invoice/[id]/+page.server.ts
@@ -1,38 +1,39 @@
+import { auth, fd, get, post } from "$lib/utils";
import { error, redirect } from "@sveltejs/kit";
-import { fd, auth, get, post } from "$lib/utils";
-export async function load({ params: { id }, parent }) {
- let { rates, user } = await parent();
+export async function load({ cookies, params: { id }, parent }) {
+ const aid = cookies.get("aid");
+ const { rates, user } = await parent();
- let invoice = await get(`/invoice/${id}`);
+ const invoice = await get(`/invoice/${id}`);
- if (invoice.prompt && invoice.tip === null)
- redirect(307, `/invoice/${id}/tip`);
+ if (invoice.prompt && invoice.tip === null)
+ redirect(307, `/invoice/${id}/tip`);
- if (invoice.memoPrompt && invoice.memo === null)
- redirect(307, `/invoice/${id}/memo`);
+ if (invoice.memoPrompt && invoice.memo === null)
+ redirect(307, `/invoice/${id}/memo`);
- if (user && invoice.account === user?.id)
- error(500, { message: "Cannot send to self" });
+ if (invoice.aid === aid) error(500, { message: "Cannot send to self" });
+ else if (user) redirect(307, `/send/${invoice.type}/${invoice.hash}`);
- if (!user) redirect(307, `/invoice/${id}`);
+ if (!user) redirect(307, `/invoice/${id}`);
- return { invoice, rates, user };
+ return { invoice, rates, user };
}
export const actions = {
- default: async ({ cookies, params: { id }, request }) => {
- let p;
- try {
- let body = await fd(request);
- body.hash = id;
+ default: async ({ cookies, params: { id }, request }) => {
+ let p;
+ try {
+ const body = await fd(request);
+ body.hash = id;
- p = await post("/payments", body, auth(cookies));
- } catch (e: any) {
- console.log("payment failed", id, e);
- error(500, e.message);
- }
+ p = await post("/payments", body, auth(cookies));
+ } catch (e: any) {
+ console.log("payment failed", id, e);
+ error(500, e.message);
+ }
- redirect(307, `/sent/${p.id}`);
- },
+ redirect(307, `/sent/${p.id}`);
+ },
};
diff --git a/src/routes/(app)/send/invoice/[id]/+page.svelte b/src/routes/(app)/send/invoice/[id]/+page.svelte
index 4348e473..fe60c9a6 100644
--- a/src/routes/(app)/send/invoice/[id]/+page.svelte
+++ b/src/routes/(app)/send/invoice/[id]/+page.svelte
@@ -48,7 +48,7 @@
amountFiat = af;
};
- let submitting;
+ let submit, submitting;
let toggle = () => (submitting = !submitting);
let external = async () => {
@@ -162,6 +162,7 @@
{currency}
bind:fiat
bind:rate
+ {submit}
/>
{/if}
@@ -188,6 +189,7 @@
</button>
{:else}
<button
+ bind:this={submit}
type="button"
class="opacity-100 hover:opacity-80'} rounded-2xl border py-5 font-bold mx-auto mt-2 bg-black text-white px-6 w-40"
on:click={setAmount}