diff --git a/src/lib/components/Catalog.svelte b/src/lib/components/Catalog.svelte
index b9c06bf..9ea0aad 100644
--- a/src/lib/components/Catalog.svelte
+++ b/src/lib/components/Catalog.svelte
@@ -1,10 +1,18 @@
{#if $catalog}
{#if $catalog.length > 0}
+
{#each $catalog as { manga }}
diff --git a/src/lib/components/ConfirmationPopup.svelte b/src/lib/components/ConfirmationPopup.svelte
new file mode 100644
index 0000000..16403cc
--- /dev/null
+++ b/src/lib/components/ConfirmationPopup.svelte
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+ {$confirmationPopupStore?.message}
+
+
+
+
+
diff --git a/src/lib/components/Modal.svelte b/src/lib/components/Modal.svelte
deleted file mode 100644
index 60d670a..0000000
--- a/src/lib/components/Modal.svelte
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
-
-
-
diff --git a/src/lib/util/index.ts b/src/lib/util/index.ts
index 8b11aef..bcdab1e 100644
--- a/src/lib/util/index.ts
+++ b/src/lib/util/index.ts
@@ -1,3 +1,4 @@
export * from './snackbar'
export * from './upload'
-export * from './misc'
\ No newline at end of file
+export * from './misc'
+export * from './modals'
\ No newline at end of file
diff --git a/src/lib/util/modals.ts b/src/lib/util/modals.ts
new file mode 100644
index 0000000..6565055
--- /dev/null
+++ b/src/lib/util/modals.ts
@@ -0,0 +1,17 @@
+import { writable } from "svelte/store";
+
+type ConfirmationPopup = {
+ open: boolean;
+ message: string;
+ onConfirm?: () => void;
+};
+export const confirmationPopupStore = writable
(undefined);
+
+export function promptConfirmation(message: string, onConfirm?: () => void) {
+ confirmationPopupStore.set({
+ open: true,
+ message,
+ onConfirm
+ });
+}
+
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte
index 00a7bff..78263c8 100644
--- a/src/routes/+layout.svelte
+++ b/src/routes/+layout.svelte
@@ -3,10 +3,12 @@
import NavBar from '$lib/components/NavBar.svelte';
import Snackbar from '$lib/components/Snackbar.svelte';
import '../app.scss';
+ import ConfirmationPopup from '$lib/components/ConfirmationPopup.svelte';
+
diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte
index ab44104..3a89bc4 100644
--- a/src/routes/+page.svelte
+++ b/src/routes/+page.svelte
@@ -2,4 +2,6 @@
import Catalog from '$lib/components/Catalog.svelte';
-
+
+
+
diff --git a/src/routes/[manga]/+page.svelte b/src/routes/[manga]/+page.svelte
index 4a9d65b..96fc94d 100644
--- a/src/routes/[manga]/+page.svelte
+++ b/src/routes/[manga]/+page.svelte
@@ -3,9 +3,9 @@
import { goto } from '$app/navigation';
import { onMount } from 'svelte';
import VolumeItem from '$lib/components/VolumeItem.svelte';
- import { Button, Modal } from 'flowbite-svelte';
- import { ExclamationCircleOutline } from 'flowbite-svelte-icons';
+ import { Button } from 'flowbite-svelte';
import { db } from '$lib/catalog/db';
+ import { promptConfirmation } from '$lib/util';
const manga = $currentManga?.sort((a, b) => {
if (a.volumeName < b.volumeName) {
@@ -17,23 +17,21 @@
return 0;
});
- let popupModal = false;
-
onMount(() => {
if (!manga) {
goto('/');
}
});
- function onDelete() {
- popupModal = true;
- }
-
async function confirmDelete() {
const title = manga?.[0].mokuroData.title_uuid;
await db.catalog.delete(title);
goto('/');
}
+
+ function onDelete() {
+ promptConfirmation('Are you sure you want to delete this manga?', confirmDelete);
+ }
@@ -49,17 +47,6 @@
-
-
-
-
- Are you sure you want to delete this manga?
-
-
-
-
-
-