// ───────────────────────────────────────────────────────────
// Huio Control Panel — CCCD Approval View (cp-cccd-view.jsx)
// ───────────────────────────────────────────────────────────
if (!window.CP_STYLES) throw new Error('[cp-cccd-view] window.CP_STYLES not loaded');
// Static style hoisting to eliminate heap allocations and GC pressure in list rendering
const STATIC_INSPECT_BTN_STYLE = { flex: 1, minHeight: '36px', fontSize: '13px' };
const STATIC_APPROVE_BTN_BASE = {
flex: 1,
minHeight: '36px',
fontSize: '13px',
color: 'var(--hu-fg-inverse)',
display: 'inline-flex',
alignItems: 'center',
justifyContent: 'center',
gap: '6px',
};
function renderCccd({
lang = 'vi',
t: rawT,
appStyles: rawAppStyles,
users: rawUsers = [],
cccdRequests: rawCccdRequests = [],
processingCccdId = null,
setSelectedRequest,
setRejectReason,
setRejectError,
handleCccdDecision,
}) {
// Defensive fallbacks for shell utilities and data structures
const appStyles = rawAppStyles || window.CP_STYLES || {};
const t = typeof rawT === 'function' ? rawT : (k) => k;
const users = Array.isArray(rawUsers) ? rawUsers : [];
const cccdRequests = Array.isArray(rawCccdRequests) ? rawCccdRequests : [];
const Icons = window.Icons || (typeof Icons !== 'undefined' ? Icons : {});
const isAnyProcessing = processingCccdId !== null;
return (
{t('cccd.title')}
{t('cccd.sub')}
{/* Interactive CCCD Status Donut Chart with defensive component resolution */}
{window.CpCharts?.CccdVerificationDonutChart ? (
) : null}
{cccdRequests.length === 0 ? (
{Icons.Info ?
: null}
{t('cccd.empty')}
) : (
{cccdRequests.map((req, idx) => {
if (!req) return null;
const isProcessing = processingCccdId === req.id;
const reqIdStr = req.id != null ? String(req.id) : `cccd_${idx}`;
const ekycProvider = req.ekycProvider ? String(req.ekycProvider) : '';
const showEkyc = ekycProvider && ekycProvider.toLowerCase() !== 'manual';
const approveBtnStyle = {
...STATIC_APPROVE_BTN_BASE,
opacity: isProcessing ? 0.8 : (isAnyProcessing ? 0.5 : 1),
};
return (
{req.name || '—'}
{t('status.pending').toUpperCase()}
{t('cccd.card.num')}:
{req.cccdNum || '—'}
{t('cccd.card.dob')}:
{req.dob || '—'}
{showEkyc ? (
{t('cccd.ekyc.provider')}:
{ekycProvider.toUpperCase()}
) : null}
);
})}
)}
);
}
window.CpCccdView = {
renderCccd,
};