'use client' import { Note } from '@/lib/types' import { Clock, FileText, Tag } 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 { language } = useLanguage() // Show only the 3 most recent notes const topThree = recentNotes.slice(0, 3) if (topThree.length === 0) return null return (
{/* Minimalist header - matching your app style */}
{language === 'fr' ? 'Récent' : 'Recent'} · {topThree.length}
{/* Compact 3-card row */}
{topThree.map((note, index) => ( ))}
) } // Compact card - matching your app's clean design function CompactCard({ note, index, onEdit }: { note: Note index: number onEdit?: (note: Note, readOnly?: boolean) => void }) { const { language } = useLanguage() // NOTE: Using updatedAt here, but note-card.tsx uses createdAt // If times are incorrect, consider using createdAt instead or ensure dates are properly parsed const timeAgo = getCompactTime(note.updatedAt, language) const isFirstNote = index === 0 return ( ) } // Compact time display - matching your app's style // NOTE: Ensure dates are properly parsed from database (may come as strings) function getCompactTime(date: Date | string, language: string): string { const now = new Date() const then = date instanceof Date ? date : new Date(date) // Validate date if (isNaN(then.getTime())) { console.warn('Invalid date provided to getCompactTime:', date) return language === 'fr' ? 'date invalide' : 'invalid date' } const seconds = Math.floor((now.getTime() - then.getTime()) / 1000) const minutes = Math.floor(seconds / 60) const hours = Math.floor(minutes / 60) if (language === 'fr') { if (seconds < 60) return 'à l\'instant' if (minutes < 60) return `il y a ${minutes}m` if (hours < 24) return `il y a ${hours}h` const days = Math.floor(hours / 24) return `il y a ${days}j` } else { if (seconds < 60) return 'just now' if (minutes < 60) return `${minutes}m ago` if (hours < 24) return `${hours}h ago` const days = Math.floor(hours / 24) return `${days}d ago` } }