diff options
| author | Adam Soltys <[email protected]> | 2024-12-05 19:20:36 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-12-05 19:20:36 -0800 |
| commit | a9b44cbae79e9c01cff07964a45e1c7efa7fb241 (patch) | |
| tree | 5caa996fc2eca705fb793e79d63bfbf5f9f93e48 /src/routes/(app)/fund | |
| parent | 6422ef30f14e1baf5d1995de69c777efcad77e32 (diff) | |
| download | coinos-ui-a9b44cbae79e9c01cff07964a45e1c7efa7fb241.tar.gz coinos-ui-a9b44cbae79e9c01cff07964a45e1c7efa7fb241.zip | |
cached rates
Diffstat (limited to 'src/routes/(app)/fund')
| -rw-r--r-- | src/routes/(app)/fund/[id]/+page.server.ts | 7 | ||||
| -rw-r--r-- | src/routes/(app)/fund/[id]/+page.svelte | 3 |
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; |
