From 350a2a46aa3b48d3223b6e5c14ddc5952d260dba Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 4 Mar 2026 12:43:18 -0800 Subject: fund ui --- .../fund/[...name]/[...amount]/+page.server.ts | 16 ++++++- .../send/fund/[...name]/[...amount]/+page.svelte | 49 +++++++++++++++------- 2 files changed, 49 insertions(+), 16 deletions(-) (limited to 'src/routes/(app)/send') diff --git a/src/routes/(app)/send/fund/[...name]/[...amount]/+page.server.ts b/src/routes/(app)/send/fund/[...name]/[...amount]/+page.server.ts index 0c4b4d96..31d6c65d 100644 --- a/src/routes/(app)/send/fund/[...name]/[...amount]/+page.server.ts +++ b/src/routes/(app)/send/fund/[...name]/[...amount]/+page.server.ts @@ -1,5 +1,5 @@ import getRates from "$lib/rates"; -import { auth, fd, post } from "$lib/utils"; +import { auth, fd, post, sats } from "$lib/utils"; import { fail, redirect } from "@sveltejs/kit"; export async function load({ parent, params }) { @@ -14,8 +14,20 @@ export async function load({ parent, params }) { export const actions = { default: async ({ cookies, request }) => { const body = await fd(request); - let p; + if (body.authorize === "true") { + const rate = Number(body.rate); + const fiat = parseFloat(((Number(body.amount) * rate) / sats).toFixed(2)); + try { + await post("/authorize", { amount: body.amount, currency: body.currency, fiat, id: body.fund }, auth(cookies)); + } catch (e) { + const { message } = e as Error; + return fail(400, { message }); + } + redirect(307, `/fund/${body.fund}`); + } + + let p; try { p = await post("/payments", body, auth(cookies)); } catch (e) { diff --git a/src/routes/(app)/send/fund/[...name]/[...amount]/+page.svelte b/src/routes/(app)/send/fund/[...name]/[...amount]/+page.svelte index baeb8795..45e76727 100644 --- a/src/routes/(app)/send/fund/[...name]/[...amount]/+page.svelte +++ b/src/routes/(app)/send/fund/[...name]/[...amount]/+page.svelte @@ -6,6 +6,7 @@ import { page } from "$app/stores"; import { fiat as fiatStore, pin } from "$lib/store"; import handler from "$lib/handler"; + import Toggle from "$comp/Toggle.svelte"; import { loc, focus, s, f, sats } from "$lib/utils"; import { applyAction, deserialize } from "$app/forms"; import { invalidateAll } from "$app/navigation"; @@ -21,6 +22,7 @@ let fiat = $state(); let locale = $derived(loc(user)); + let authorize = $state(false); let submit = $state(); let submitting: boolean = $state(false); let toggle = () => (submitting = !submitting); @@ -58,29 +60,48 @@ + + + + +
+ {$t("funds.immediateContribution")} + + {$t("funds.fiatAuthorization")} +
+

+ {#if authorize} + {$t("funds.authorizeDesc")} + {:else} + {$t("funds.contributeDesc")} + {/if} +

- + {#if !authorize} + + {/if}
+ -- cgit v1.2.3