"use client"; import Link from "next/link"; import { formatDate, isToday } from "@/lib/utils/date"; import { MoodIcon } from "./MoodSelector"; import { TagChips } from "./TagInput"; import type { EntryWithTags } from "@/lib/types"; interface EntryRowProps { entry: EntryWithTags; searchQuery?: string; } function highlightText(text: string, query: string): React.ReactNode { if (!query.trim()) return text; const regex = new RegExp(`(${query.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})`, "gi"); const parts = text.split(regex); return parts.map((part, i) => regex.test(part) ? ( {part} ) : ( part ) ); } export function EntryRow({ entry, searchQuery = "" }: EntryRowProps) { // Truncate text to one line preview const preview = entry.text.length > 80 ? entry.text.slice(0, 80) + "..." : entry.text; return (
{isToday(entry.date) ? "Today" : formatDate(entry.date)} {entry.roughDay ? ( rough day ) : null}

{highlightText(preview, searchQuery)}

{entry.tags.length > 0 && (
)}
{entry.mood && (
)}
); }