'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 ( onEdit?.(note)} className={cn( "group relative text-left p-4 bg-card border rounded-xl shadow-sm hover:shadow-md transition-all duration-200 min-h-[44px]", isFirstNote && "ring-2 ring-primary/20" )} > {note.title || t('notes.untitled')} {note.content?.substring(0, 80) || ''} {note.content && note.content.length > 80 && '...'} {timeAgo} {note.notebookId && ( )} {note.labels && note.labels.length > 0 && ( )} ) } 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 }) }
{note.content?.substring(0, 80) || ''} {note.content && note.content.length > 80 && '...'}