diff options
| author | Adam Soltys <[email protected]> | 2025-07-07 22:34:27 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2025-07-07 22:34:27 -0700 |
| commit | 209b1e64f1c4dda16a50e57c6570a3a35953085d (patch) | |
| tree | 4e8b260e5b8f832b03dd41f17f65b42aba58f268 /src/routes/(app)/fund | |
| parent | 1b1718a4b64275bac8e1fe519d33c67e3a95f2c5 (diff) | |
| download | coinos-ui-209b1e64f1c4dda16a50e57c6570a3a35953085d.tar.gz coinos-ui-209b1e64f1c4dda16a50e57c6570a3a35953085d.zip | |
fund sweep
Diffstat (limited to 'src/routes/(app)/fund')
| -rw-r--r-- | src/routes/(app)/fund/[id]/+page.svelte | 8 | ||||
| -rw-r--r-- | src/routes/(app)/fund/[id]/sweep/+page.server.ts | 24 | ||||
| -rw-r--r-- | src/routes/(app)/fund/[id]/sweep/+page.svelte | 8 |
3 files changed, 28 insertions, 12 deletions
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 @@ ></iconify-icon> <div class="my-auto">{$t("payments.shareLink")}</div> </a> + <button + on:click={() => copy(`${$page.url.href}/sweep`)} + class="btn !w-auto grow" + > + <iconify-icon noobserver icon="ph:copy-bold" width="32" + ></iconify-icon> + <div class="my-auto">{$t("payments.sweep")}</div> + </button> <!-- <a href={`/qr/${lnurlw}`} class="btn !w-auto grow"> --> <!-- <iconify-icon --> <!-- noobserver --> 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 @@ </script> <div class="container px-4 max-w-xl mx-auto mt-10 space-y-5 text-center"> - <div class="w-full flex"> - <a href="/" class="mx-auto"> - <Icon icon="logo" /> - </a> - </div> - <div class="flex w-full py-5 max-w-[200px] mx-auto" in:scale={{ start: 0.5 }}> <Icon icon="check" style="mx-auto" /> </div> @@ -32,7 +26,7 @@ </h3> </div> -<a href={`/payments`}> +<a href={`/${user.username}`}> <div class="opacity-0 w-screen h-screen fixed top-0 left-0 z-50"></div> </a> |
