diff --git a/src/components/modals/EditProjectsModal.svelte b/src/components/modals/EditProjectsModal.svelte index b07a4a8a..eea9d5e3 100644 --- a/src/components/modals/EditProjectsModal.svelte +++ b/src/components/modals/EditProjectsModal.svelte @@ -4,12 +4,31 @@ import type { Project } from '$ts/common/types'; import ModalShell from './ModalShell.svelte'; import api from '$ts/client/api'; + import { writable } from 'svelte/store'; export let projects: Project[]; - const deleteProject = async (projectId: string) => { - await api.project.delete(projectId); - await invalidateAll(); + let showConfirmation = writable(false); + let projectToDelete: string | null = null; + + const confirmDelete = (projectId: string) => { + projectToDelete = projectId; + showConfirmation.set(true); + }; + + const deleteProject = async () => { + if (projectToDelete) { + await api.project.delete(projectToDelete); + await invalidateAll(); + // Close the confirmation dialog after deletion + showConfirmation.set(false); + projectToDelete = null; + } + }; + + const cancelDelete = () => { + showConfirmation.set(false); + projectToDelete = null; }; @@ -37,10 +56,29 @@ class="rounded-md border border-yellow-500 bg-yellow-600 p-1 px-2 text-sm">Edit {/each} {/if} + +{#if $showConfirmation} +
Are you sure you want to delete this project?
+