'use client' import { useRouter } from 'next/navigation' import { Dialog, DialogContent, DialogTitle } from '@/components/ui/dialog' import { SourceDetailContent } from './SourceDetailContent' import { useTranslation } from '@/lib/hooks/use-translation' interface SourceDialogProps { open: boolean onOpenChange: (open: boolean) => void sourceId: string | null } /** * Source Dialog Component * * Displays source details in a modal dialog. * Includes a "Chat with source" button that navigates to the full source page in-app. */ export function SourceDialog({ open, onOpenChange, sourceId }: SourceDialogProps) { const { t } = useTranslation() const router = useRouter() // Ensure source ID has 'source:' prefix for API calls and routing const sourceIdWithPrefix = sourceId ? (sourceId.includes(':') ? sourceId : `source:${sourceId}`) : null const handleChatClick = () => { if (sourceIdWithPrefix) { onOpenChange(false) router.push(`/sources/${sourceIdWithPrefix}`) } } const handleClose = () => { onOpenChange(false) } if (!sourceIdWithPrefix) { return null } return ( {/* Accessibility title (hidden visually but read by screen readers) */} {t('sources.detailsTitle')} {/* Source detail content */}
) }