summaryrefslogblamecommitdiffstatshomepage
path: root/frontend/src/lib/tabs/ArchiveDelete.svelte
blob: b0e3c582aca20a2a2cf3f01f4541088a016505b6 (plain) (tree)









































                                                                                                                         
<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>