summaryrefslogblamecommitdiffstatshomepage
path: root/frontend/src/lib/toolbar/MarkFavourite.svelte
blob: 1af5d608943c427848d096ece4c97298032e24b7 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                  
                                                       
                                                  


                                                                              



                                                
                                                                                        

                                             
                                                                                                   


         
                                                                                         


                                 
                                                                                          


                                  
<script lang="ts">
	import type { MutationWith } from '$gql/Utils';
	import Star from '$lib/icons/Star.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<{ favourite: boolean }> } = $props();

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

<button type="button" class="btn-slate justify-start gap-1" onclick={() => mutate(true)}>
	<Star favourite={true} />
	<span>Favourite</span>
</button>
<button type="button" class="btn-slate justify-start gap-1" onclick={() => mutate(false)}>
	<Star favourite={false} />
	<span>Unfavourite</span>
</button>