blob: 26db3e4ed4406c926419458236bc18b71856bf83 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
<script lang="ts">
import Button from "$lib/ui/button.svelte";
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;
const url = await init_auth_session();
location.href = url;
navigating = false;
}
async function logout() {
await clear_auth_session();
}
</script>
<main>
{#if data.sb1.accounts?.length}
<ul>
{#each data.sb1.accounts as account}
<li>{account.name}</li>
{#if (await get_transactions(account.key))?.length}
<ul>
{#each await get_transactions(account.key) as transaction}
<li>{JSON.stringify(transaction)}</li>
{/each}
</ul>
{:else}
<small>Ingen transaksjoner</small>
{/if}
{/each}
</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>
|