"use client"; import { X } from "lucide-react"; import { useEffect } from "react"; import { WellnessSlider } from "@/components/daily-quiz/wellness-slider"; import { Button } from "@/components/ui/button"; import { formatSleepHours, SLEEP_HOURS_MAX, SLEEP_HOURS_MIN, SLEEP_HOURS_STEP, type DailyQuizSubmission, } from "@/lib/avatar-state"; type JournalEntryModalProps = { entry: DailyQuizSubmission | null; onClose: () => void; }; function formatEntryDateLabel(dateKey: string) { const [year, month, day] = dateKey.split("-").map(Number); const date = new Date(year, month - 1, day); return date.toLocaleDateString(undefined, { weekday: "long", month: "long", day: "numeric", year: "numeric", }); } export function JournalEntryModal({ entry, onClose }: JournalEntryModalProps) { useEffect(() => { if (!entry) { return; } const handleKeyDown = (event: KeyboardEvent) => { if (event.key === "Escape") { onClose(); } }; window.addEventListener("keydown", handleKeyDown); return () => { window.removeEventListener("keydown", handleKeyDown); }; }, [entry, onClose]); if (!entry) { return null; } const journalText = entry.journal.trim(); return (
event.stopPropagation()} >

Journal entry

{formatEntryDateLabel(entry.date)}

Daily journal

{journalText || "No journal written."}

Wellness

undefined} /> undefined} /> undefined} /> undefined} /> undefined} />
); }