"use client"; import type { MailEnvelope } from "@/app/[lang]/dashboard/mail/page"; function timeAgo(dateStr: string): string { const now = new Date(); const d = new Date(dateStr); const diff = now.getTime() - d.getTime(); const mins = Math.floor(diff / 60000); if (mins < 1) return "şimdi"; if (mins < 60) return `${mins}dk`; const hrs = Math.floor(mins / 60); if (hrs < 24) return `${hrs}sa`; const days = Math.floor(hrs / 24); if (days < 7) return `${days}g`; return d.toLocaleDateString("tr-TR", { day: "numeric", month: "short" }); } function senderName(msg: MailEnvelope): string { const f = msg.from[0]; return f?.name || f?.address || "Bilinmeyen"; } export default function MessageList({ messages, loading, selectedUid, onSelect, onDelete }: { messages: MailEnvelope[]; loading: boolean; selectedUid: number | null; onSelect: (uid: number) => void; onDelete: (uid: number) => void; }) { if (loading) { return
; } if (messages.length === 0) { return (
Bu klasörde mail yok
); } return (
{messages.map((m) => (
onSelect(m.uid)} >
{senderName(m)[0]?.toUpperCase() ?? "?"}
{senderName(m)} {timeAgo(m.date)}
{m.subject}
{m.hasAttachments && 📎}
))}
); }