fix: resolve merge conflict in SourceInsightDialog

Add missing state variables and handlers for delete functionality
that were lost during merge of PRs #334 and #340
This commit is contained in:
LUIS NOVO 2025-12-19 23:10:49 -03:00
parent d6eedde5a3
commit 79f4d5ea6a

View file

@ -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<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
@ -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">