54 lines
1.7 KiB
Svelte
54 lines
1.7 KiB
Svelte
<script lang="ts">
|
|
import { resolve } from '$app/paths';
|
|
import { Button } from '#lib/components/ui/button/index.js';
|
|
import * as Card from '#lib/components/ui/card/index.js';
|
|
import * as Alert from '#lib/components/ui/alert/index.js';
|
|
import type { PageProps } from './$types';
|
|
|
|
let { data }: PageProps = $props();
|
|
let copied = $state(false);
|
|
async function copy() {
|
|
await navigator.clipboard.writeText(data.fullUrl);
|
|
copied = true;
|
|
}
|
|
</script>
|
|
|
|
<svelte:head
|
|
><title>Bank connection · Money tracker</title><meta
|
|
name="robots"
|
|
content="noindex"
|
|
/></svelte:head
|
|
>
|
|
|
|
<section class="mx-auto max-w-xl space-y-6 p-6">
|
|
<h1 class="text-2xl font-bold">Bank connection</h1>
|
|
{#if data.error}
|
|
<Alert.Root variant="destructive"
|
|
><Alert.Title>Revolut did not grant access</Alert.Title><Alert.Description
|
|
>{data.error}{data.errorDescription ? `: ${data.errorDescription}` : ''}. Run
|
|
<code>scripts/bank-link.ts</code> again to retry.</Alert.Description
|
|
></Alert.Root
|
|
>
|
|
{:else if data.code}
|
|
<Card.Root
|
|
><Card.Header
|
|
><Card.Title>Almost done</Card.Title><Card.Description
|
|
>Copy this address and paste it into the waiting <code>bank-link</code> prompt. The code is
|
|
single-use and expires within minutes.</Card.Description
|
|
></Card.Header
|
|
><Card.Content class="space-y-3"
|
|
><code class="block break-all rounded bg-muted p-3 text-xs">{data.fullUrl}</code><Button
|
|
onclick={copy}>{copied ? 'Copied' : 'Copy address'}</Button
|
|
></Card.Content
|
|
></Card.Root
|
|
>
|
|
{:else}
|
|
<p>
|
|
No authorisation code in this link. Start a connection with <code>scripts/bank-link.ts</code>.
|
|
</p>
|
|
{/if}
|
|
<p>
|
|
<a class="underline" href={resolve('/projects/money-tracker')}>Back to the money tracker</a>
|
|
</p>
|
|
</section>
|