// Global changes feed function ChangesFeed({ onOpenAccount }) { const data = window.FABCOM_DATA; const [dateRange, setDateRange] = useState("7d"); const [account, setAccount] = useState(""); const [actor, setActor] = useState(""); const [eventType, setEventType] = useState(""); const [query, setQuery] = useState(""); const actors = [...new Set(data.history.map(h => h.actor))].sort(); const events = [...new Set(data.history.map(h => h.event_type))]; const days = dateRange === "24h" ? 1 : dateRange === "7d" ? 7 : dateRange === "14d" ? 14 : 30; const cutoff = Date.now() - days*86400e3; const filtered = data.history.filter(h => { if (h.ts < cutoff) return false; if (account && h.account_id !== account) return false; if (actor && h.actor !== actor) return false; if (eventType && h.event_type !== eventType) return false; if (query) { const q = query.toLowerCase(); if (!(h.entity_name.toLowerCase().includes(q) || String(h.new_value).toLowerCase().includes(q) || String(h.old_value).toLowerCase().includes(q))) return false; } return true; }); const byAccount = useMemo(() => Object.fromEntries(data.accounts.map(a => [a.id, a])), []); return (
| When | Account | Entity | Actor | Event | Field | Before → After |
|---|---|---|---|---|---|---|
{window.timeAgo(h.ts)} {window.formatFullTs(h.ts)} |
{h.account_id}
|
{h.entity_id}
|
{h.actor} | {h.field} |