Adding await tick before updating creditLineRef in editCard() function. Also spread some async

This commit is contained in:
qowevisa 2024-11-23 20:29:05 +02:00
parent 2462dce25a
commit 1785e24623

View File

@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { onMount } from "svelte"; import { onMount, tick } from "svelte";
import { type Card, type Currency } from "$lib/entities"; import { type Card, type Currency } from "$lib/entities";
import { NumberToFPA } from "$lib/util/fpa"; import { NumberToFPA } from "$lib/util/fpa";
@ -70,11 +70,12 @@
} }
} }
function editCard(card: Card) { async function editCard(card: Card) {
editingCard = { ...card }; editingCard = { ...card };
if (balanceRef) { if (balanceRef) {
balanceRef.value = NumberToFPA(card.balance); balanceRef.value = NumberToFPA(card.balance);
} }
await tick();
if (creditLineRef) { if (creditLineRef) {
creditLineRef.value = NumberToFPA(card.credit_line); creditLineRef.value = NumberToFPA(card.credit_line);
} }