import React from 'react';
const PRIORITY_CONFIG = {
5: { color: '#ef4444', bg: 'rgba(239,68,68,0.12)', label: 'CRITICAL', textColor: '#fca5a5' },
4: { color: '#f59e0b', bg: 'rgba(245,158,11,0.12)', label: 'HIGH', textColor: '#fcd34d' },
3: { color: '#eab308', bg: 'rgba(234,179,8,0.10)', label: 'MEDIUM', textColor: '#fde047' },
2: { color: '#22c55e', bg: 'rgba(34,197,94,0.10)', label: 'LOW', textColor: '#86efac' },
1: { color: '#94a3b8', bg: 'rgba(148,163,184,0.08)', label: 'MINIMAL', textColor: '#cbd5e1' },
};
const ACTION_ICONS = {
reply: '↩',
schedule: '📅',
delegate: '→',
ignore: '✕',
};
function UrgencyRing({ urgency, priority }) {
const pct = Math.max(0, Math.min(1, urgency));
const size = 36;
const stroke = 3;
const r = (size - stroke * 2) / 2;
const circ = 2 * Math.PI * r;
const dash = circ * pct;
const color = PRIORITY_CONFIG[priority]?.color || '#94a3b8';
return (
{(urgency * 100).toFixed(0)}
);
}
export default function InboxPanel({ emails, selectedEmailId, onSelect, isAutoRunning }) {
const sorted = [...emails].sort((a, b) => {
if (a.handled !== b.handled) return a.handled ? 1 : -1;
if (b.priority !== a.priority) return b.priority - a.priority;
return b.urgency - a.urgency;
});
return (
📥 Inbox
{emails.filter(e => !e.handled).length} unhandled
{sorted.map(email => {
const cfg = PRIORITY_CONFIG[email.priority] || PRIORITY_CONFIG[1];
const isSelected = email.id === selectedEmailId;
const isHandled = email.handled;
const isAiFocus = isSelected && isAutoRunning;
return (
!isHandled && !isAutoRunning && onSelect && onSelect(email)}
>
P{email.priority} {cfg.label}
{isHandled && (
{ACTION_ICONS[email.action_taken]} {email.action_taken}
)}
{!isHandled &&
}
{isHandled &&
✓}
{email.sender.split('<')[0].trim()}
{email.subject}
{isSelected && !isHandled && (
{email.body}
)}
);
})}
);
}