const API_BASE_EMAIL = window.__LARAVEL_API_URL || 'https://api.techyfuel.com/api'; // Email screen — reads/sends through a mailbox via IMAP/SMTP (api/email-list.js, // api/email-message.js, api/email-send.js, api/email-accounts.js). No OAuth -- // this is for plain cPanel/Hostinger-style mailboxes. By default it uses the // one shared TechyFuel inbox (Vercel env vars) but each team member can also // connect their own separate mailbox from here; those credentials are // encrypted server-side and never touch the client, keyed to whoever is // signed in (verified from their own Supabase session token on every call). (() => { const { Badge } = window.TechyFuelOSDesignSystem_be0222; async function authHeader() { try { const { data } = await window.db.auth.getSession(); const token = data?.session?.access_token; return token ? { Authorization: `Bearer ${token}` } : {}; } catch { return {}; } } function fmtWhen(ds) { if (!ds) return ''; const d = new Date(ds); const now = new Date(); const sameDay = d.toDateString() === now.toDateString(); return sameDay ? d.toLocaleTimeString('en', { hour: 'numeric', minute: '2-digit' }) : d.toLocaleDateString('en', { month: 'short', day: 'numeric' }); } // Normalize an address that the API may send as an object ({name,address}), // a plain string, or null (bounce / system mail) — so we never show a raw blank. function addrText(a) { if (!a) return ''; if (typeof a === 'string') return a; return a.name || a.address || ''; } function MessageRow({ msg, active, onClick, mailbox }) { const [hover, setHover] = React.useState(false); const isSent = mailbox === 'sent'; const who = isSent ? (addrText(msg.to && msg.to[0]) || 'Unknown recipient') : (addrText(msg.from) || 'Unknown sender'); const seen = !msg.unseen; // backend sends `unseen`, not `seen` return (
{mailbox === 'announcements' ? `${announcements.length} announcements` : `${messages.length} messages in ${mailbox === 'sent' ? 'sent' : 'inbox'}`}