From 209b1e64f1c4dda16a50e57c6570a3a35953085d Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 7 Jul 2025 22:34:27 -0700 Subject: fund sweep --- src/routes/(app)/fund/[id]/+page.svelte | 8 +++++++ src/routes/(app)/fund/[id]/sweep/+page.server.ts | 24 ++++++++++++++++----- src/routes/(app)/fund/[id]/sweep/+page.svelte | 8 +------ src/routes/(app)/send/[...text]/+page.svelte | 27 ++++++++++++------------ 4 files changed, 42 insertions(+), 25 deletions(-) (limited to 'src/routes/(app)') diff --git a/src/routes/(app)/fund/[id]/+page.svelte b/src/routes/(app)/fund/[id]/+page.svelte index f1a1838e..614616af 100644 --- a/src/routes/(app)/fund/[id]/+page.svelte +++ b/src/routes/(app)/fund/[id]/+page.svelte @@ -111,6 +111,14 @@ >
{$t("payments.shareLink")}
+ diff --git a/src/routes/(app)/fund/[id]/sweep/+page.server.ts b/src/routes/(app)/fund/[id]/sweep/+page.server.ts index 5bb42fa4..3e0b8dad 100644 --- a/src/routes/(app)/fund/[id]/sweep/+page.server.ts +++ b/src/routes/(app)/fund/[id]/sweep/+page.server.ts @@ -1,13 +1,27 @@ -import { get, auth, post } from "$lib/utils"; +import { randomName, randomPassword } from "$lib/random"; +import getRates from "$lib/rates"; +import { auth, get, post, register } from "$lib/utils"; import { redirect } from "@sveltejs/kit"; -export async function load({ cookies, params, parent }) { - const { user } = await parent(); +export async function load({ cookies, request, params, parent }) { + let { user } = await parent(); const { id } = params; const { amount } = await get(`/fund/${id}`); + const rates = await getRates(); + const rate = rates[user?.currency || "USD"]; if (!amount) redirect(307, `/fund/${id}`); - if (!user) redirect(307, `/register?redirect=/fund/${id}/sweep`); + if (!user) { + const ip = request.headers.get("cf-connecting-ip"); + + user = { + username: randomName(), + password: randomPassword(), + }; + + await register(user, ip, cookies, `/fund/${id}/sweep`); + } + await post("/take", { amount, id }, auth(cookies)); - return { amount, id }; + return { amount, id, rate, rates }; } diff --git a/src/routes/(app)/fund/[id]/sweep/+page.svelte b/src/routes/(app)/fund/[id]/sweep/+page.svelte index cd89f6ae..0523b85a 100644 --- a/src/routes/(app)/fund/[id]/sweep/+page.svelte +++ b/src/routes/(app)/fund/[id]/sweep/+page.svelte @@ -12,12 +12,6 @@
-
- - - -
-
@@ -32,7 +26,7 @@
- +
diff --git a/src/routes/(app)/send/[...text]/+page.svelte b/src/routes/(app)/send/[...text]/+page.svelte index 183b4b51..e5c77647 100644 --- a/src/routes/(app)/send/[...text]/+page.svelte +++ b/src/routes/(app)/send/[...text]/+page.svelte @@ -73,18 +73,7 @@ {/if} - - - +
+ + + -- cgit v1.2.3