"use client"; import { CornerDownRight, GitBranch } from "lucide-react"; import { Badge } from "@/shared/components/ui/badge"; import type { RegistryEntry } from "../types"; import { cn } from "@/shared/lib/utils"; interface ThreadViewProps { /** The current entry being viewed */ entry: RegistryEntry; /** All entries in the registry (to resolve references) */ allEntries: RegistryEntry[]; /** Click on an entry to navigate to it */ onNavigate?: (entry: RegistryEntry) => void; } /** * Shows thread relationships for a registry entry: * - Parent entry (this is a reply to...) * - Child entries (replies to this entry) * Displays as an indented tree with direction badges. */ export function ThreadView({ entry, allEntries, onNavigate }: ThreadViewProps) { // Find the parent entry (if this is a reply) const parent = entry.threadParentId ? allEntries.find((e) => e.id === entry.threadParentId) : null; // Find child entries (replies to this entry) const children = allEntries.filter((e) => e.threadParentId === entry.id); // Find siblings (other replies to the same parent, excluding this one) const siblings = entry.threadParentId ? allEntries.filter( (e) => e.threadParentId === entry.threadParentId && e.id !== entry.id, ) : []; if (!parent && children.length === 0) return null; return (
Fir conversație
{/* Parent */} {parent && (

Răspuns la:

{/* Siblings — other branches from same parent */} {siblings.length > 0 && (

Alte ramuri ({siblings.length}):

{siblings.map((s) => ( ))}
)}
)} {/* Current entry marker */}
{entry.number} {entry.subject}
{/* Children — replies to this entry */} {children.length > 0 && (

Răspunsuri ({children.length}):

{children.map((child) => ( ))}
)}
); } function ThreadEntryChip({ entry, onNavigate, dimmed, }: { entry: RegistryEntry; onNavigate?: (entry: RegistryEntry) => void; dimmed?: boolean; }) { return ( ); } function formatDate(iso: string): string { try { return new Date(iso).toLocaleDateString("ro-RO", { day: "2-digit", month: "2-digit", year: "numeric", }); } catch { return iso; } }