aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2025-07-18 08:40:39 -0700
committerAdam Soltys <[email protected]>2025-07-18 08:40:39 -0700
commit4fc61539d923cdee874b07a5f1576dad11bd091a (patch)
treec5fb4b5b0ab7cdf8e3a8f201bfcbaf51ef785447 /src
parent84d04961a8fc91765837746e98545e8f109a9aa6 (diff)
downloadcoinos-ui-4fc61539d923cdee874b07a5f1576dad11bd091a.tar.gz
coinos-ui-4fc61539d923cdee874b07a5f1576dad11bd091a.zip
sweep fiat amounts
Diffstat (limited to 'src')
-rw-r--r--src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts (renamed from src/routes/(app)/fund/[id]/sweep/+page.server.ts)15
-rw-r--r--src/routes/(app)/fund/[id]/sweep/[...amount]/+page.svelte (renamed from src/routes/(app)/fund/[id]/sweep/+page.svelte)0
2 files changed, 12 insertions, 3 deletions
diff --git a/src/routes/(app)/fund/[id]/sweep/+page.server.ts b/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts
index d8415ca4..61a66fd2 100644
--- a/src/routes/(app)/fund/[id]/sweep/+page.server.ts
+++ b/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.server.ts
@@ -1,14 +1,23 @@
import { randomName, randomPassword } from "$lib/random";
import getRates from "$lib/rates";
-import { auth, get, post, register } from "$lib/utils";
-import { redirect } from "@sveltejs/kit";
+import { auth, get, post, register, sats } from "$lib/utils";
+import { error, redirect } from "@sveltejs/kit";
export async function load({ cookies, request, params, parent }) {
let { user } = await parent();
const { id } = params;
- const { amount } = await get(`/fund/${id}`);
+ let [amount, currency] = params.amount.split("/");
+
const rates = await getRates();
const rate = rates[user?.currency || "USD"];
+ if (currency && !rate) error(500, "Invalid currency symbol");
+
+ if (!amount) {
+ const balance = await get(`/fund/${id}`);
+ amount = balance.amount;
+ } else if (currency) {
+ amount = (amount * sats) / rate;
+ }
const username = randomName();
const password = randomPassword();
diff --git a/src/routes/(app)/fund/[id]/sweep/+page.svelte b/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.svelte
index adba77ae..adba77ae 100644
--- a/src/routes/(app)/fund/[id]/sweep/+page.svelte
+++ b/src/routes/(app)/fund/[id]/sweep/[...amount]/+page.svelte