~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0
45 lines · 1.1 KB Raw History
<script lang="ts">
	import Button from '#lib/atoms/Button.svelte';
	import AccountList from '#lib/organisms/AccountList.svelte';
	import Card from '#lib/templates/Card.svelte';
	import { call, follow } from '#lib/api';
	import { byHandle, type Known } from '#lib/data';
	import { leaveAlert, words } from '#lib/words';

	let {
		known,
		onchoose,
		onanother
	}: {
		known: Known[];
		onchoose: (k: Known) => void;
		onanother: () => void;
	} = $props();

	let busy = $state(false);
	let alert = $state('');
	let ended = $state(false);

	async function cancel() {
		busy = true;
		alert = '';
		const a = await call('reject', {});
		if (follow(a)) return;
		busy = false;
		alert = leaveAlert(a);
		ended = a.status === 400;
	}
</script>

<Card heading={words.chooseAccount} {alert}>
	<AccountList known={byHandle(known)} disabled={busy || ended} {onchoose} />
	{#snippet actions()}
		<Button
			label={words.anotherAccount}
			icon="person-add"
			disabled={busy || ended}
			onclick={onanother}
		/>
		<Button label={words.cancel} {busy} disabled={busy || ended} onclick={cancel} />
	{/snippet}
</Card>