From 8eb6cfb222c6c438374421b4e3918372a66e28b5 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 13 Feb 2026 21:08:25 -0800 Subject: get currency from account --- src/components/Account.svelte | 8 +- src/components/Balance.svelte | 5 +- src/components/InvoiceData.svelte | 5 +- src/locales/en.json | 3 +- .../(app)/[username]/(profile)/+layout.server.ts | 2 +- .../(app)/[username]/(profile)/+layout.svelte | 3 +- .../(app)/[username]/(profile)/+page.server.ts | 2 +- src/routes/(app)/[username]/(profile)/+page.svelte | 4 +- src/routes/(app)/account/[id]/+page.server.ts | 8 +- src/routes/(app)/account/[id]/+page.svelte | 155 +++++++++++++++++++-- src/routes/(app)/settings/account/+page.svelte | 114 +-------------- 11 files changed, 171 insertions(+), 138 deletions(-) (limited to 'src') diff --git a/src/components/Account.svelte b/src/components/Account.svelte index df2c51ea..d588932a 100644 --- a/src/components/Account.svelte +++ b/src/components/Account.svelte @@ -12,7 +12,9 @@ import { arkkey } from "$lib/ark"; import { getRememberedWalletPassword, forgetWalletPassword } from "$lib/passwordCache"; - let { user, rate, account }: any = $props(); + let { user, rates, account }: any = $props(); + let currency = $derived(account.currency || user.currency); + let rate = $derived(rates[currency]); let { name, seed, fingerprint, balance, pending, id, type: accountType, arkAddress } = $derived(account); let arkBalance = $state(0); @@ -135,10 +137,10 @@
{displayName}
- + {#if pending}
- +{$fiat && rate ? f(toFiat(pending, rate), user.currency, loc(user)) : s(pending)} pending + +{$fiat && rate ? f(toFiat(pending, rate), currency, loc(user)) : s(pending)} pending
{/if}
diff --git a/src/components/Balance.svelte b/src/components/Balance.svelte index 440c260d..6abb1449 100644 --- a/src/components/Balance.svelte +++ b/src/components/Balance.svelte @@ -6,8 +6,9 @@ import { t } from "$lib/translations"; let show = $state(); - let { id, user, rate, balance } = $props(); - let { currency, locked } = $derived(user); + let { id, user, rate, balance, currency: currencyProp = undefined } = $props(); + let currency = $derived(currencyProp || user.currency); + let { locked } = $derived(user); let locale = $derived(loc(user)); let toggleShow = (e) => { e.preventDefault(); diff --git a/src/components/InvoiceData.svelte b/src/components/InvoiceData.svelte index 84a52308..105eb471 100644 --- a/src/components/InvoiceData.svelte +++ b/src/components/InvoiceData.svelte @@ -19,6 +19,7 @@ }: any = $props(); let loaded = $state(false); + let expanded = $state(false); let { memo } = $derived(invoice); let load = () => (loaded = true); @@ -52,11 +53,11 @@ diff --git a/src/locales/en.json b/src/locales/en.json index 93fe95a8..9f23dd47 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -70,7 +70,8 @@ "bitcoin": "Bitcoin", "custodial": "Custodial", "submit": "Submit", - "type": "Type" + "type": "Type", + "accountType": "Account type" }, "404": { "404": "404", diff --git a/src/routes/(app)/[username]/(profile)/+layout.server.ts b/src/routes/(app)/[username]/(profile)/+layout.server.ts index 9c916d7a..9fd42861 100644 --- a/src/routes/(app)/[username]/(profile)/+layout.server.ts +++ b/src/routes/(app)/[username]/(profile)/+layout.server.ts @@ -6,5 +6,5 @@ export async function load({ depends, parent }) { const rates = await getRates(); const { subject } = await parent(); - return { rate: rates[subject.currency] }; + return { rates }; } diff --git a/src/routes/(app)/[username]/(profile)/+layout.svelte b/src/routes/(app)/[username]/(profile)/+layout.svelte index 61aa38d5..39aca251 100644 --- a/src/routes/(app)/[username]/(profile)/+layout.svelte +++ b/src/routes/(app)/[username]/(profile)/+layout.svelte @@ -10,7 +10,8 @@ let { encode, toWords } = bech32; - let { rate, user, subject } = $derived(data); + let { rates, user, subject } = $derived(data); + let rate = $derived(rates[subject.currency]); let { events, src, text } = $derived(data as any); let satsPerCurrency = $derived((1 * sats) / rate); diff --git a/src/routes/(app)/[username]/(profile)/+page.server.ts b/src/routes/(app)/[username]/(profile)/+page.server.ts index 9c97c947..f5be6aae 100644 --- a/src/routes/(app)/[username]/(profile)/+page.server.ts +++ b/src/routes/(app)/[username]/(profile)/+page.server.ts @@ -11,5 +11,5 @@ export async function load({ cookies, depends, parent }) { if (cookies.get("token")) accounts = await get("/accounts", auth(cookies)); const rates = await getRates(); - return { accounts, rate: rates[subject.currency] }; + return { accounts, rates }; } diff --git a/src/routes/(app)/[username]/(profile)/+page.svelte b/src/routes/(app)/[username]/(profile)/+page.svelte index 60af01c8..966925d5 100644 --- a/src/routes/(app)/[username]/(profile)/+page.svelte +++ b/src/routes/(app)/[username]/(profile)/+page.svelte @@ -15,7 +15,7 @@ preloadData("/send"); }); - let { accounts, subject, rate, user } = $derived(data as any); + let { accounts, subject, rates, user } = $derived(data as any); let { locked } = $derived(user); let install = async () => { @@ -62,7 +62,7 @@ {#if user?.id && user.id === subject.id}
{#each accounts as account} - + {/each}
diff --git a/src/routes/(app)/account/[id]/+page.server.ts b/src/routes/(app)/account/[id]/+page.server.ts index 0fcfbdd9..8e16f839 100644 --- a/src/routes/(app)/account/[id]/+page.server.ts +++ b/src/routes/(app)/account/[id]/+page.server.ts @@ -1,9 +1,11 @@ import { error, redirect } from "@sveltejs/kit"; import { auth, get, post, fd } from "$lib/utils"; +import getRates from "$lib/rates"; export const load = async ({ cookies, params }) => { const account = await get(`/account/${params.id}`, auth(cookies)); - return { account }; + const rates = await getRates(); + return { account, rates }; }; export const actions = { @@ -12,6 +14,10 @@ export const actions = { const body = await fd(request); const username = cookies.get("username"); + body.autowithdraw = body.autowithdraw === "on"; + if (body.threshold) body.threshold = parseInt(body.threshold); + if (body.reserve) body.reserve = parseInt(body.reserve); + try { await post(`/account/${id}`, body, auth(cookies)); } catch (e: any) { diff --git a/src/routes/(app)/account/[id]/+page.svelte b/src/routes/(app)/account/[id]/+page.svelte index 05add104..fa9d744d 100644 --- a/src/routes/(app)/account/[id]/+page.svelte +++ b/src/routes/(app)/account/[id]/+page.svelte @@ -1,11 +1,14 @@