"use client"; import { use, useEffect } from "react"; import { useJournalEntry } from "@/hooks/use-journals"; import { usePageRefresh } from "@/hooks"; import { Button } from "@/components/ui/button"; import { Tooltip, TooltipContent, TooltipTrigger, } from "@/components/ui/tooltip"; import { HelpTip } from "@/components/ui/help-tip"; import { Badge } from "@/components/ui/badge"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Skeleton } from "@/components/ui/skeleton"; import { Markdown } from "@/components/ui/markdown"; import { EntryTypeBadge } from "@/components/journals/entry-type-badge"; import { CopyButton } from "@/components/ui/copy-button"; import { ArrowLeft, AlertTriangle, Clock, Tag, Link2, User, } from "lucide-react"; import Link from "next/link"; interface JournalEntryPageProps { params: Promise<{ entryId: string }>; } function formatFullDate(timestamp: string): string { const date = new Date(timestamp); return date.toLocaleDateString("en-US", { weekday: "long", year: "numeric", month: "long", day: "numeric", hour: "2-digit", minute: "2-digit", }); } export default function JournalEntryPage({ params }: JournalEntryPageProps) { const { entryId } = use(params); const { data: entry, isLoading, error, refetch } = useJournalEntry(entryId); const { register, unregister } = usePageRefresh(); useEffect(() => { const cb = () => { void refetch(); }; register(cb); return () => unregister(cb); }, [register, unregister, refetch]); // Loading state if (isLoading) { return (
); } // Error state if (error || !entry) { return (

Entry Not Found

{error?.message ?? "The journal entry you're looking for doesn't exist or has been deleted."}

); } return (
{/* Header */}
Back to journals
{entry.sentiment && ( {entry.sentiment} )}

{entry.title}

{/* Metadata */}
Created

{formatFullDate(entry.timestamp)}

Journal

{entry.journal_id.slice(0, 8)}

{entry.task_id && (
Related Task
Task #{entry.task_id.slice(0, 8)}
)}
{/* Content */} Content
{entry.content}
{/* Tags */} {entry.tags.length > 0 && ( Tags
{entry.tags.map((tag) => ( {tag} ))}
)}
); }