aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/routes/(app)/account/[id]/+page.server.ts3
-rw-r--r--src/routes/(app)/account/[id]/+page.svelte14
2 files changed, 17 insertions, 0 deletions
diff --git a/src/routes/(app)/account/[id]/+page.server.ts b/src/routes/(app)/account/[id]/+page.server.ts
index 8e16f839..1a4e63eb 100644
--- a/src/routes/(app)/account/[id]/+page.server.ts
+++ b/src/routes/(app)/account/[id]/+page.server.ts
@@ -20,6 +20,9 @@ export const actions = {
try {
await post(`/account/${id}`, body, auth(cookies));
+ if (body.updateUserCurrency === "on") {
+ await post("/user", { currency: body.currency }, auth(cookies));
+ }
} catch (e: any) {
console.log(e);
error(400, { message: e.message });
diff --git a/src/routes/(app)/account/[id]/+page.svelte b/src/routes/(app)/account/[id]/+page.svelte
index 674cb067..3abc4bdc 100644
--- a/src/routes/(app)/account/[id]/+page.svelte
+++ b/src/routes/(app)/account/[id]/+page.svelte
@@ -31,6 +31,14 @@
);
let name = $state(data.account.name || displayType);
let currency = $state(data.account.currency || data.user.currency);
+ let userCurrency = $derived(data.user.currency);
+ let currencyChanged = $derived(currency !== userCurrency);
+ let updateUserCurrency = $state(false);
+
+ $effect(() => {
+ updateUserCurrency = currencyChanged;
+ });
+
let autowithdraw = $state(data.account.autowithdraw || false);
let threshold = $state(data.account.threshold || data.user.threshold || 1000000);
let reserve = $state(data.account.reserve ?? 0);
@@ -198,6 +206,12 @@
</select>
</div>
+ {#if currencyChanged}
+ <div class="flex justify-between items-center">
+ <span>Also update default currency to {currency}</span>
+ <Toggle id="updateUserCurrency" bind:value={updateUserCurrency} />
+ </div>
+ {/if}
{#if isCustodial}
<div>