"use client"; // Panneau source : extrait exact, contexte voisin, métadonnées du document. import { useEffect, useState } from "react"; import { FileText, X } from "lucide-react"; import { Badge, Skeleton } from "@/components/ui"; export type Citation = { tag: string; index: number; courseCode: string | null; docTitle: string; filename: string; refLabel: string; title: string; excerpt: string; chunkId: number; }; type SourceDetail = { source: { ref_label: string; title: string; display_content: string; section_title: string; doc_title: string; filename: string; course_code: string | null; ingested_at: string | null; week: number | null; }; neighbors: { id: number; ref_number: number; title: string; preview: string }[]; }; export function CitationPanel({ citation, onClose }: { citation: Citation | null; onClose: () => void }) { const [detail, setDetail] = useState(null); const [loading, setLoading] = useState(false); useEffect(() => { if (!citation) return; setDetail(null); setLoading(true); fetch(`/api/citations/${citation.chunkId}`) .then((r) => (r.ok ? r.json() : null)) .then((d) => setDetail(d)) .finally(() => setLoading(false)); }, [citation]); if (!citation) return null; return (
); }