// ─────────────────────────────────────────────────────────── // Huio Control Panel — Dashboard View (cp-dashboard-view.jsx) // ─────────────────────────────────────────────────────────── if (!window.CP_STYLES) throw new Error('[cp-dashboard-view] window.CP_STYLES not loaded'); function renderDashboard({ lang = 'vi', t: rawT, appStyles: rawAppStyles, users: rawUsers = [], groups: rawGroups = [], logs: rawLogs = [], dbStats = {}, errorLogs: rawErrorLogs = [], isConnected = false, }) { const appStyles = rawAppStyles || window.CP_STYLES || {}; const t = typeof rawT === 'function' ? rawT : (k) => k; const users = Array.isArray(rawUsers) ? rawUsers : []; const groups = Array.isArray(rawGroups) ? rawGroups : []; const logs = Array.isArray(rawLogs) ? rawLogs : []; const errorLogs = Array.isArray(rawErrorLogs) ? rawErrorLogs : []; const vndShort = window.vndShort || ((amount) => { if (amount === undefined || amount === null) return "0 ₫"; if (amount >= 1e9) return (amount / 1e9).toFixed(1) + "B ₫"; if (amount >= 1e6) return (amount / 1e6).toFixed(1) + "M ₫"; if (amount >= 1e3) return (amount / 1e3).toFixed(0) + "k ₫"; return amount + " ₫"; }); const totalDbRows = Object.values(dbStats || {}).reduce((a, b) => Number(a || 0) + Number(b || 0), 0); const errors24h = errorLogs.filter(e => new Date(e.created_at || Date.now()) > new Date(Date.now() - 24 * 3600 * 1000)).length; return (
{t('dashboard.sub')}