diff --git a/frontend/src/routes/admin/accounts/+page.svelte b/frontend/src/routes/admin/accounts/+page.svelte index 1b0be27..0269fe8 100644 --- a/frontend/src/routes/admin/accounts/+page.svelte +++ b/frontend/src/routes/admin/accounts/+page.svelte @@ -5,6 +5,7 @@ import { accountsApi } from '$lib/requests/requests'; import { formatPrice } from '$lib/utils'; import { onMount } from 'svelte'; + import ReadCard from '$lib/components/readCard.svelte'; let accounts: Account[] = []; let newAccount: NewAccount = { @@ -38,7 +39,8 @@ let deletingAccount: boolean = false; let confirmationMessage: string | undefined = undefined; let deleteAccountCallback: VoidFunction = () => {}; - + let selectedAccount: Account | undefined = undefined; + let askForCard = false; onMount(() => { reloadAccounts(); }); @@ -89,6 +91,34 @@ reloadAccounts(); }); } + + function changeCardId(account: Account | undefined, card_id: string) { + if (account != undefined) { + accountsApi() + .patchAccountId( + account.id, + { + card_id: card_id + }, + { withCredentials: true } + ) + .then((res) => { + account = res.data ?? account; + }) + .catch((err) => { + if (account != undefined) { + account.card_id = account.card_id ?? ''; + } + }); + } else { + console.log('test'); + } + } + + function reset() { + askForCard = false; + selectedAccount = undefined; + } {#if shown_refill} @@ -100,534 +130,582 @@ /> {/if} - -