aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/fund
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-12-05 19:20:36 -0800
committerAdam Soltys <[email protected]>2024-12-05 19:20:36 -0800
commit53aecbf35d056fc4d70ef1ab12d3634b265f2c0b (patch)
tree5caa996fc2eca705fb793e79d63bfbf5f9f93e48 /src/routes/(app)/fund
parent9c7ade85841e4e608fd9d8468d19b42b79cd9868 (diff)
downloadcoinos-ui-53aecbf35d056fc4d70ef1ab12d3634b265f2c0b.tar.gz
coinos-ui-53aecbf35d056fc4d70ef1ab12d3634b265f2c0b.zip
cached rates
Diffstat (limited to 'src/routes/(app)/fund')
-rw-r--r--src/routes/(app)/fund/[id]/+page.server.ts7
-rw-r--r--src/routes/(app)/fund/[id]/+page.svelte3
2 files changed, 7 insertions, 3 deletions
diff --git a/src/routes/(app)/fund/[id]/+page.server.ts b/src/routes/(app)/fund/[id]/+page.server.ts
index bc07d721..668ea3af 100644
--- a/src/routes/(app)/fund/[id]/+page.server.ts
+++ b/src/routes/(app)/fund/[id]/+page.server.ts
@@ -1,7 +1,12 @@
+import getRates from "$lib/rates";
import { auth, get, post } from "$lib/utils";
import { redirect } from "@sveltejs/kit";
-export const load = async ({ params: { id } }) => get(`/fund/${id}`);
+export const load = async ({ params: { id } }) => {
+ const data = await get(`/fund/${id}`);
+ data.rate = await getRates();
+ return data;
+};
export const actions = {
default: async ({ cookies, locals, params }) => {
diff --git a/src/routes/(app)/fund/[id]/+page.svelte b/src/routes/(app)/fund/[id]/+page.svelte
index 0931075a..23dce871 100644
--- a/src/routes/(app)/fund/[id]/+page.svelte
+++ b/src/routes/(app)/fund/[id]/+page.svelte
@@ -11,13 +11,12 @@
let { data } = $props();
- let { amount, src, payments, rates, user } = data;
+ let { amount, src, payments, rate, user } = data;
let { id } = $page.params;
toast.pop(0);
let currency = user ? user.currency : "CAD";
- let rate = rates[currency];
let amountFiat = $derived(parseFloat(((amount * rate) / sats).toFixed(2)));
$loginRedirect = $page.url.pathname;