/* AAU CRM — Call Log + QC, Inbox Daily Report, Data Sync Explorer */ /* ── Date range + period comparison ── */ const REPORT_TODAY = new Date('2026-06-02T00:00:00'); const CMP_PROFILE = { none: null, prev: { label: 'kỳ trước liền kề', shift: 'adjacent', f: 0.9, respond: 89, frt: 4.7, qc: 7.6, callQc: 6.6, pass: 44 }, lastmonth: { label: 'cùng kỳ tháng trước', shift: 30, f: 0.8, respond: 86, frt: 5.3, qc: 7.3, callQc: 6.4, pass: 41 }, }; function fmtDM(d) { return ('0' + d.getDate()).slice(-2) + '/' + ('0' + (d.getMonth() + 1)).slice(-2); } function rangeDays(range, custom) { if (range === 'custom') { const p = s => { const [d, m, y] = s.split('/').map(Number); return new Date(y, m - 1, d); }; try { return Math.max(1, Math.round((p(custom.to) - p(custom.from)) / 864e5) + 1); } catch (e) { return 14; } } return { '1d': 1, '7d': 7, '30d': 30 }[range] || 1; } function spanForDays(days, endOffset = 0) { const end = new Date(REPORT_TODAY); end.setDate(end.getDate() - endOffset); const start = new Date(end); start.setDate(start.getDate() - (days - 1)); return { label: fmtDM(start) + ' – ' + fmtDM(end) }; } function compareSpan(days, cmpKey) { const p = CMP_PROFILE[cmpKey]; if (!p) return null; return p.shift === 'adjacent' ? spanForDays(days, days) : spanForDays(days, p.shift); } function deltaPct(cur, cmp) { return cmp ? Math.round(((cur - cmp) / cmp) * 100) : 0; } function DateRangeBar({ range, setRange, custom, setCustom, cmp, setCmp }) { const days = rangeDays(range, custom); const cur = range === 'custom' ? { label: custom.from + ' – ' + custom.to } : spanForDays(days); const cs = compareSpan(days, cmp); return (
{range === 'custom' && ( setCustom({ ...custom, from: v })} style={{ width: 132 }} /> setCustom({ ...custom, to: v })} style={{ width: 132 }} /> )} {cur.label} · {days} ngày So sánh với: ({ value: u.id, label: u.name }))]} style={{ width: 132 }} /> ({ value: v, label: o.l }))]} style={{ width: 140 }} /> {}} style={{ width: 168 }} />
)} {tab === 'transcript' && (
Click một dòng để tua tới đoạn ghi âm tương ứng. Từ khóa quan trọng được tô sáng.
{SAMPLE_TRANSCRIPT.map((l, i) => { const sc = { pos: '#0a9e6e', neu: '#8a8a8a', neg: '#c4320a' }[l.s]; return (
setPlaying(true)} className="row g10" style={{ cursor: 'pointer' }}> {l.t}
{l.who === 'agent' ? 'Agent' : 'Khách'}
{hl(l.text, open.kw)}
{l.viol && Vi phạm: {l.viol}}
); })} {open.kw.length > 0 &&
{open.kw.map(k => {k})}
}
)} {tab === 'coaching' && (
GỬI NHẬN XÉT CHO {(open.agentName || '').toUpperCase()}