aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/routes/+page.svelte
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/routes/+page.svelte')
-rw-r--r--app/src/routes/+page.svelte41
1 files changed, 22 insertions, 19 deletions
diff --git a/app/src/routes/+page.svelte b/app/src/routes/+page.svelte
index e89df9b..26db3e4 100644
--- a/app/src/routes/+page.svelte
+++ b/app/src/routes/+page.svelte
@@ -1,10 +1,10 @@
<script lang="ts">
import Button from "$lib/ui/button.svelte";
- import { onMount } from "svelte";
- import { clear_auth_session, get_accounts, get_transactions, init_auth_session, is_ready } from "./sb1.remote";
- import { get_actual_meta } from "./actual.remote";
+ import { clear_auth_session, get_transactions, init_auth_session } from "./sb1.remote";
+ import type { PageProps } from "./$types";
let navigating = $state(false);
+ let { data }: PageProps = $props();
async function authorize() {
navigating = true;
@@ -16,23 +16,16 @@
async function logout() {
await clear_auth_session();
}
-
- onMount(async () => {
- await get_actual_meta();
- });
</script>
<main>
- {#if await is_ready()}
- {@const accounts = await get_accounts()}
- {@const actual_meta = await get_actual_meta()}
- {#if accounts}
- {#each accounts?.accounts as account}
- {@const transactions = await get_transactions(account.key)}
+ {#if data.sb1.accounts?.length}
+ <ul>
+ {#each data.sb1.accounts as account}
<li>{account.name}</li>
- {#if transactions?.length}
+ {#if (await get_transactions(account.key))?.length}
<ul>
- {#each transactions as transaction}
+ {#each await get_transactions(account.key) as transaction}
<li>{JSON.stringify(transaction)}</li>
{/each}
</ul>
@@ -40,12 +33,22 @@
<small>Ingen transaksjoner</small>
{/if}
{/each}
- {/if}
- {#if actual_meta}
- <pre>{JSON.stringify(actual_meta, null, 2)}</pre>
- {/if}
+ </ul>
<Button onclick={logout}>Logg ut</Button>
{:else}
<Button onclick={authorize} loading={navigating}>Autentisér hos Sparebanken 1</Button>
{/if}
+
+ {#if data.actual.meta}
+ <pre>{JSON.stringify(data.actual.meta, null, 2)}</pre>
+ {/if}
</main>
+
+<style>
+ main {
+ display: flex;
+ justify-content: center;
+ width: 100%;
+ height: 90vh;
+ }
+</style>