'use client' import { useEffect, useState } from 'react' import { Link2, ChevronRight, Loader2 } from 'lucide-react' import { cn } from '@/lib/utils' import { motion, AnimatePresence } from 'motion/react' import { useRouter } from 'next/navigation' import { useLanguage } from '@/lib/i18n' interface BacklinkNote { id: string title: string | null updatedAt: string notebookId: string | null } interface Backlink { id: string sourceNote: BacklinkNote contextSnippet: string | null createdAt: string } interface WikilinksBacklinksPanelProps { noteId: string className?: string } export function WikilinksBacklinksPanel({ noteId, className }: WikilinksBacklinksPanelProps) { const { t } = useLanguage() const [backlinks, setBacklinks] = useState([]) const [loading, setLoading] = useState(true) const [open, setOpen] = useState(true) const router = useRouter() useEffect(() => { if (!noteId) return setLoading(true) fetch(`/api/notes/${noteId}/backlinks`) .then(r => r.json()) .then(data => setBacklinks(data.backlinks || [])) .catch(() => {}) .finally(() => setLoading(false)) }, [noteId]) if (loading && backlinks.length === 0) return null if (!loading && backlinks.length === 0) return null return (
{/* Header */} {open && ( {loading && (
{t('common.loading') || 'Chargement…'}
)} {backlinks.map(bl => ( ))}
)}
) }