@@ -3,6 +3,7 @@ import { onBeforeUnmount, ref, computed, watch } from 'vue'
33import { useBoardStore } from ' ../../store/boardStore'
44import { useSessionStore } from ' ../../store/sessionStore'
55import { useEscapeToClose } from ' ../../composables/useEscapeToClose'
6+ import TdDialog from ' ../ui/TdDialog.vue'
67import type { Card , CardCaptureProvenance , Label } from ' ../../types/board'
78import type { CardComment } from ' ../../types/comments'
89import { normalizeProposalStatus } from ' ../../utils/automation'
@@ -37,6 +38,11 @@ const captureProvenance = ref<CardCaptureProvenance | null>(null)
3738const captureProvenanceError = ref <string | null >(null )
3839const loadingCaptureProvenance = ref (false )
3940const loadedCaptureProvenanceCardId = ref <string | null >(null )
41+ const showDeleteConfirm = ref (false )
42+ const isDeleting = ref (false )
43+ const deleteConfirmDescription = computed (
44+ () => ` Are you sure you want to delete "${props .card .title }"? This action cannot be undone. `
45+ )
4046
4147const comments = computed <CardComment []>(() => boardStore .getCardComments (props .card .id ))
4248const topLevelComments = computed (() => comments .value .filter (comment => ! comment .parentCommentId ))
@@ -158,15 +164,26 @@ async function handleSave() {
158164 }
159165}
160166
161- async function handleDelete() {
162- if (! confirm (` Are you sure you want to delete "${props .card .title }"? ` )) return
167+ function handleDeleteClick() {
168+ showDeleteConfirm .value = true
169+ }
170+
171+ function handleDeleteCancel() {
172+ showDeleteConfirm .value = false
173+ }
163174
175+ async function handleDeleteConfirm() {
176+ if (isDeleting .value ) return
177+ isDeleting .value = true
164178 try {
165179 await boardStore .deleteCard (props .card .boardId , props .card .id )
180+ showDeleteConfirm .value = false
166181 emit (' updated' )
167182 emit (' close' )
168183 } catch (error ) {
169184 console .error (' Failed to delete card:' , error )
185+ } finally {
186+ isDeleting .value = false
170187 }
171188}
172189
@@ -593,7 +610,7 @@ onBeforeUnmount(() => {
593610 <!-- Actions -->
594611 <div class =" mt-6 flex items-center justify-between" >
595612 <button
596- @click =" handleDelete "
613+ @click =" handleDeleteClick "
597614 type =" button"
598615 class =" px-4 py-2 text-sm font-medium text-red-600 hover:text-red-700 hover:bg-red-50 border border-red-300 rounded-md transition-colors"
599616 >
@@ -620,4 +637,32 @@ onBeforeUnmount(() => {
620637 </div >
621638 </div >
622639 </div >
640+
641+ <!-- Delete Confirmation Dialog -->
642+ <TdDialog
643+ :open =" showDeleteConfirm"
644+ title =" Delete Card"
645+ :description =" deleteConfirmDescription"
646+ :close-on-backdrop =" !isDeleting"
647+ @close =" handleDeleteCancel"
648+ >
649+ <template #footer >
650+ <button
651+ type =" button"
652+ :disabled =" isDeleting"
653+ class =" px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50 border border-gray-300 rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
654+ @click =" handleDeleteCancel"
655+ >
656+ Cancel
657+ </button >
658+ <button
659+ type =" button"
660+ :disabled =" isDeleting"
661+ class =" px-4 py-2 text-sm font-medium text-white bg-red-600 hover:bg-red-700 border border-transparent rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
662+ @click =" handleDeleteConfirm"
663+ >
664+ {{ isDeleting ? 'Deleting…' : 'Delete' }}
665+ </button >
666+ </template >
667+ </TdDialog >
623668</template >
0 commit comments