Files
chitai/frontend/src/lib/components/forms/book-delete.svelte
T
patrick 3a29294f96 chore: clear the mechanical lint and type findings
Dead imports and locals removed, each blocks keyed, `any` narrowed to unknown.
Two context setters kept their calls and lost only the unused binding; the
settings redirect no longer awaits a parent whose data it discards. A leading
underscore now marks a binding that only holds a position.
2026-08-17 17:55:21 -04:00

55 lines
1.4 KiB
Svelte

<script lang="ts">
import * as Field from '$lib/components/ui/field/index.js';
import { Checkbox } from '$lib/components/ui/checkbox/index.js';
import { Button } from '$lib/components/ui/button/index.js';
import * as Dialog from '$lib/components/ui/dialog/index.js';
let {
open = $bindable(),
title = 'Delete book?',
deleteFn
}: {
open: boolean;
title?: string;
deleteFn: (deleteFiles: boolean) => void | Promise<void>;
} = $props();
let deleteFiles = $state(false);
</script>
<Dialog.Root bind:open>
<Dialog.Content class="sm:max-w-[425px]">
<Dialog.Header>
<Dialog.Title>{title}</Dialog.Title>
<Dialog.Description>
This will delete the book(s) from the database, and optionally delete the files from the
filesystem.
</Dialog.Description>
</Dialog.Header>
<Field.Set>
<Field.Group>
<!-- Delete files checkbox -->
<Field.Field>
<div class="flex items-center gap-2">
<Checkbox bind:checked={deleteFiles} />
<Field.Label class="font-normal">Delete files from the filesystem</Field.Label>
</div>
</Field.Field>
</Field.Group>
</Field.Set>
<!-- Buttons -->
<Dialog.Footer class="ml-auto flex">
<Button variant="outline" onclick={() => (open = false)}>Cancel</Button>
<Button
onclick={async () => {
open = false;
await deleteFn(deleteFiles);
}}
variant="destructive">Delete</Button
>
</Dialog.Footer>
</Dialog.Content>
</Dialog.Root>