From 377c928372de16273636ed079d2c8781d6c5dcf1 Mon Sep 17 00:00:00 2001 From: qowevisa Date: Sun, 24 Nov 2024 11:35:55 +0200 Subject: [PATCH] Update UI for expense page --- src/routes/expense/+page.svelte | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/routes/expense/+page.svelte b/src/routes/expense/+page.svelte index cd46c56..8fa4e67 100644 --- a/src/routes/expense/+page.svelte +++ b/src/routes/expense/+page.svelte @@ -20,7 +20,7 @@ onMount(async () => { await fetchCategories(); - await fetchCards(); + await fetchCards(true); await fetchTypes(); }); @@ -33,8 +33,12 @@ types = await result.json(); } } - async function fetchCards() { - const result = await fetch("/api/card/all"); + async function fetchCards(preloadCurrencies = false) { + const queryParams = new URLSearchParams({ + preload_currencies: preloadCurrencies.toString(), + }); + + const result = await fetch(`/api/card/all?${queryParams}`); if (!result.ok) { const obj = await result.json(); error = obj.message; @@ -169,7 +173,7 @@ class="mt-1 block w-full px-4 py-2 border border-gray-300 rounded-md focus:ring focus:ring-indigo-200 focus:border-indigo-500" > {#each cards as card} - + {/each} @@ -255,13 +259,10 @@ class="bg-white p-4 rounded-lg shadow-md flex justify-between items-center" >
- {NumberToFPA(expense.value)} + {expense.show_value}
Card: - {getCardName(expense.card_id)} - {`•${cards.find((card) => card.id == expense.card_id)?.last_digits}`} + {expense.card.display_name} Type: {getTypeName(expense.type_id)}