'use client' import { Note } from '@/lib/types' import { Clock } from 'lucide-react' import { cn } from '@/lib/utils' import { useLanguage } from '@/lib/i18n' interface RecentNotesSectionProps { recentNotes: Note[] onEdit?: (note: Note, readOnly?: boolean) => void } export function RecentNotesSection({ recentNotes, onEdit }: RecentNotesSectionProps) { const { t } = useLanguage() const topThree = recentNotes.slice(0, 3) if (topThree.length === 0) return null return (
{t('notes.recent')} ยท {topThree.length}
{topThree.map((note, index) => ( ))}
) } function CompactCard({ note, index, onEdit }: { note: Note index: number onEdit?: (note: Note, readOnly?: boolean) => void }) { const { t } = useLanguage() const timeAgo = getCompactTime(note.contentUpdatedAt || note.updatedAt, t) const isFirstNote = index === 0 return ( ) } function getCompactTime(date: Date | string, t: (key: string, params?: Record) => string): string { const now = new Date() const then = date instanceof Date ? date : new Date(date) if (isNaN(then.getTime())) { console.warn('Invalid date provided to getCompactTime:', date) return t('common.error') } const seconds = Math.floor((now.getTime() - then.getTime()) / 1000) const minutes = Math.floor(seconds / 60) const hours = Math.floor(minutes / 60) if (seconds < 60) return t('time.justNow') if (minutes < 60) return t('time.minutesAgo', { count: minutes }) if (hours < 24) return t('time.hoursAgo', { count: hours }) const days = Math.floor(hours / 24) return t('time.daysAgo', { count: days }) }