summaryrefslogtreecommitdiffstatshomepage
path: root/frontend/src/lib/tabs/ArchiveDelete.svelte
blob: b0e3c582aca20a2a2cf3f01f4541088a016505b6 (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
35
36
37
38
39
40
41
42
<script lang="ts">
	import { goto } from '$app/navigation';
	import { deleteArchives } from '$gql/Mutations';
	import type { FullArchiveFragment } 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 archive: FullArchiveFragment;

	function deleteArchive() {
		confirmDeletion('Archive', archive.name, () => {
			deleteArchives(client, { ids: archive.id })
				.then(() => goto('/archives/'))
				.catch(toastFinally);
		});
	}
</script>

<div class="flex flex-col gap-2">
	<div>
		<p>
			Deleting this archive will remove the
			<span class="cursor-help font-medium underline" title={archive.path}>archive file</span> on disk.
		</p>
		{#if archive.comics.length > 0}
			<p>The following comics will also be deleted:</p>
			<ul class="ml-8 list-disc">
				{#each archive.comics as comic}
					<li><a href="/comics/{comic.id}" class="underline">{comic.title}</a></li>
				{/each}
			</ul>
		{/if}
		<p class="mt-2 font-medium">This action is irrevocable.</p>
	</div>
	<div class="flex">
		<DeleteButton prominent on:click={deleteArchive} />
	</div>
</div>