summaryrefslogtreecommitdiffstatshomepage
path: root/frontend/src/lib/tabs/ComicDelete.svelte
blob: a10f6b262a9989e88f4fb229cf0a57e317008693 (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
<script lang="ts">
	import { goto } from '$app/navigation';
	import { deleteComics } from '$gql/Mutations';
	import type { FullComicFragment } from '$gql/graphql';
	import { toastFinally } from '$lib/Toasts';
	import { confirmDeletion } from '$lib/Utils';
	import DeleteButton from '$lib/components/DeleteButton.svelte';
	import { getContextClient } from '@urql/svelte';

	const client = getContextClient();

	export let comic: FullComicFragment;

	function deleteComic() {
		confirmDeletion('Comic', comic.title, () => {
			deleteComics(client, { ids: comic.id })
				.then(() => goto('/comics/'))
				.catch(toastFinally);
		});
	}
</script>

<div class="flex flex-col gap-2">
	<div>
		<p>
			Deleting this comic will make all of its pages available again for allocation. All of its
			metadata will be lost.
		</p>
		<p class="mt-2 font-medium">This action is irrevocable.</p>
	</div>
	<div class="flex">
		<DeleteButton prominent on:click={deleteComic} />
	</div>
</div>