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:
parent
d6eedde5a3
commit
79f4d5ea6a
1 changed files with 23 additions and 2 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import { useState, useEffect } from 'react'
|
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 { Badge } from '@/components/ui/badge'
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
import { FileText } from 'lucide-react'
|
import { FileText } from 'lucide-react'
|
||||||
|
|
@ -23,8 +23,10 @@ interface SourceInsightDialogProps {
|
||||||
onDelete?: (insightId: string) => Promise<void>
|
onDelete?: (insightId: string) => Promise<void>
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SourceInsightDialog({ open, onOpenChange, insight }: SourceInsightDialogProps) {
|
export function SourceInsightDialog({ open, onOpenChange, insight, onDelete }: SourceInsightDialogProps) {
|
||||||
const { openModal } = useModalManager()
|
const { openModal } = useModalManager()
|
||||||
|
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false)
|
||||||
|
const [isDeleting, setIsDeleting] = useState(false)
|
||||||
|
|
||||||
// Ensure insight ID has 'source_insight:' prefix for API calls
|
// Ensure insight ID has 'source_insight:' prefix for API calls
|
||||||
const insightIdWithPrefix = insight?.id
|
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 (
|
return (
|
||||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||||
<DialogContent className="sm:max-w-3xl max-h-[90vh] flex flex-col">
|
<DialogContent className="sm:max-w-3xl max-h-[90vh] flex flex-col">
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue