Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions frontend/src/components/source/SourceInsightDialog.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -23,8 +23,10 @@ interface SourceInsightDialogProps {
onDelete?: (insightId: string) => Promise<void>
}

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
Expand All @@ -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 (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="sm:max-w-3xl max-h-[90vh] flex flex-col">
Expand Down
Loading