diff --git a/frontend/src/components/source/SourceInsightDialog.tsx b/frontend/src/components/source/SourceInsightDialog.tsx index 1ff3ad5..35e8fb7 100644 --- a/frontend/src/components/source/SourceInsightDialog.tsx +++ b/frontend/src/components/source/SourceInsightDialog.tsx @@ -1,7 +1,7 @@ 'use client' import { useState, useEffect } from 'react' -import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from '@/components/ui/dialog' +import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog' import { Badge } from '@/components/ui/badge' import { Button } from '@/components/ui/button' import { FileText } from 'lucide-react' @@ -23,8 +23,10 @@ interface SourceInsightDialogProps { onDelete?: (insightId: string) => Promise } -export function SourceInsightDialog({ open, onOpenChange, insight }: SourceInsightDialogProps) { +export function SourceInsightDialog({ open, onOpenChange, insight, onDelete }: SourceInsightDialogProps) { const { openModal } = useModalManager() + const [showDeleteConfirm, setShowDeleteConfirm] = useState(false) + const [isDeleting, setIsDeleting] = useState(false) // Ensure insight ID has 'source_insight:' prefix for API calls const insightIdWithPrefix = insight?.id @@ -45,6 +47,25 @@ export function SourceInsightDialog({ open, onOpenChange, insight }: SourceInsig } } + const handleDelete = async () => { + if (!insight?.id || !onDelete) return + setIsDeleting(true) + try { + await onDelete(insight.id) + onOpenChange(false) + } finally { + setIsDeleting(false) + setShowDeleteConfirm(false) + } + } + + // Reset delete confirmation when dialog closes + useEffect(() => { + if (!open) { + setShowDeleteConfirm(false) + } + }, [open]) + return (