From a9b44cbae79e9c01cff07964a45e1c7efa7fb241 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 5 Dec 2024 19:20:36 -0800 Subject: cached rates --- src/routes/(app)/fund/[id]/+page.server.ts | 7 ++++++- src/routes/(app)/fund/[id]/+page.svelte | 3 +-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src/routes/(app)/fund') 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; -- cgit v1.2.3