'use client'
import Link from 'next/link'
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
import { Badge } from '@/components/ui/badge'
import { ArrowRight, Link2, RefreshCw, ExternalLink, Users } from 'lucide-react'
interface BacklinkInfo {
id: string
sourceNoteId: string
targetNoteId: string
sourceNote: {
id: string
title: string
type: string
}
}
interface RelatedNote {
id: string
title: string
type: string
tags: string[]
score: number
reason: string
}
interface NoteConnectionsProps {
noteId: string
backlinks: BacklinkInfo[]
outgoingLinks: BacklinkInfo[]
relatedNotes: RelatedNote[]
coUsedNotes: { noteId: string; title: string; type: string; weight: number }[]
}
function ConnectionGroup({
title,
icon: Icon,
notes,
emptyMessage,
}: {
title: string
icon: React.ComponentType<{ className?: string }>
notes: { id: string; title: string; type: string }[]
emptyMessage: string
}) {
if (notes.length === 0) {
return (
)
}
return (
{title}
{notes.length}
{notes.map((note) => (
{note.title}
))}
)
}
export function NoteConnections({
noteId,
backlinks,
outgoingLinks,
relatedNotes,
coUsedNotes,
}: NoteConnectionsProps) {
const hasAnyConnections =
backlinks.length > 0 || outgoingLinks.length > 0 || relatedNotes.length > 0 || coUsedNotes.length > 0
if (!hasAnyConnections) {
return null
}
return (
Conectado con
{/* Backlinks - notes that link TO this note */}
({
id: bl.sourceNote.id,
title: bl.sourceNote.title,
type: bl.sourceNote.type,
}))}
emptyMessage="NingĂșn otro documento enlaza a esta nota"
/>
{/* Outgoing links - notes this note links TO */}
({
id: ol.sourceNote.id,
title: ol.sourceNote.title,
type: ol.sourceNote.type,
}))}
emptyMessage="Esta nota no enlaza a ningĂșn otro documento"
/>
{/* Related notes - by content similarity and scoring */}
({
id: rn.id,
title: rn.title,
type: rn.type,
}))}
emptyMessage="No hay notas relacionadas"
/>
{/* Co-used notes - often viewed together */}
({
id: cu.noteId,
title: cu.title,
type: cu.type,
}))}
emptyMessage="No hay notas co-usadas"
/>
)
}