'use client' import Link from 'next/link' import { Star, Paperclip } from 'lucide-react' import { cn } from '@/lib/utils' import { Skeleton } from '@/components/ui/skeleton' export interface MessageListItem { uid: number from: { name: string; address: string } | null subject: string date: string flags: string[] preview: string } interface MessageListProps { messages: MessageListItem[] folder: string loading?: boolean selectedUid?: number } function formatDate(dateStr: string): string { const date = new Date(dateStr) const now = new Date() const diffMs = now.getTime() - date.getTime() const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24)) if (diffDays === 0) { return date.toLocaleTimeString(undefined, { hour: '2-digit', minute: '2-digit' }) } if (diffDays === 1) return 'Yesterday' if (diffDays < 7) { return date.toLocaleDateString(undefined, { weekday: 'short' }) } return date.toLocaleDateString(undefined, { month: 'short', day: 'numeric' }) } function senderDisplay(from: { name: string; address: string } | null): string { if (!from) return 'Unknown' return from.name || from.address } function senderInitial(from: { name: string; address: string } | null): string { const display = senderDisplay(from) return display.charAt(0).toUpperCase() } export function MessageList({ messages, folder, loading, selectedUid }: MessageListProps) { if (loading) { return (
No messages
{msg.subject}
{msg.preview && ({msg.preview}
)}