// ─────────────────────────────────────────────────────────── // 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, urgentCounts = {}, onNavigate = () => {}, }) { 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 = urgentCounts.errorsCount ?? errorLogs.filter(e => new Date(e.created_at || Date.now()) > new Date(Date.now() - 24 * 3600 * 1000)).length; const bankReviewCount = urgentCounts.bankReviewCount || 0; const dlqCount = urgentCounts.dlqCount || 0; const cccdPendingCount = urgentCounts.cccdCount || users.filter(u => u.status === 'pending').length; const supportCount = urgentCounts.supportCount || 0; // Exclude system bots, CP admins, and single test account Thường from dashboard business stats const isExcluded = window.isExcludedAccount || ((id) => { if (!id) return false; const str = String(id).toLowerCase(); return str.startsWith('a0000000') || str === '0ef8985e-a4df-4b87-9bc5-8368ec96668e' || str === '53524201-43e8-43ab-adc1-47f9ef9adc0d' || str.startsWith('4b6ad40d'); }); const realUsers = users.filter(u => !isExcluded(u) && !u.isTester && !u.isDemo && !u.deletedAt); const realGroups = groups.filter(g => !isExcluded(g.organizer_id) && !users.some(u => u.id === g.organizer_id && (u.isTester || u.isDemo || u.deletedAt))); // Paid subscribers (real payments via Sepay/bank) vs manual staff grants const paidUsersCount = realUsers.filter(u => u.subscriptionSource === 'payment').length; const grantUsersCount = realUsers.filter(u => u.subscriptionSource === 'cp_grant' && u.plan && u.plan !== 'free').length; return (
{t('dashboard.sub')}
{lang === 'vi' ? 'Các mục công việc cần Admin hoặc Moderator duyệt và xử lý đối soát.' : 'Pending queues requiring administrator attention.'}