summaryrefslogtreecommitdiffstatshomepage
path: root/frontend/src/lib/toolbar/MarkOrganized.svelte
blob: 63c8622449834435ed10532d0ed94d82356edbe9 (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
<script lang="ts">
	import type { MutationWith } from '$gql/Utils';
	import Organized from '$lib/icons/Organized.svelte';
	import { getSelectionContext } from '$lib/selection/Selection.svelte';
	import { toastFinally } from '$lib/Toasts';
	import { getContextClient } from '@urql/svelte';

	const client = getContextClient();
	const selection = getSelectionContext();

	let { mutation }: { mutation: MutationWith<{ organized: boolean }> } = $props();

	function mutate(organized: boolean) {
		mutation(client, { ids: selection.ids, input: { organized } }).catch(toastFinally);
	}
</script>

<button type="button" class="btn-slate flex justify-start gap-1" onclick={() => mutate(true)}>
	<Organized tristate organized={true} />
	<span>Organized</span>
</button>
<button type="button" class="btn-slate flex justify-start gap-1" onclick={() => mutate(false)}>
	<Organized dim tristate organized={false} />
	<span>Unorganized</span>
</button>