import type { IDailyConversation } from '../../service/agent-analytics/agent-analytics.interface'; import { RECOMAZE_COLORS } from './helpers'; export const OVERVIEW_LINE_CHART_OPTIONS = { plugins: { legend: { display: false } }, scales: { x: { grid: { display: false }, ticks: { font: { size: 10 }, maxTicksLimit: 10 }, }, y: { beginAtZero: true, grid: { color: '#f3f4f6' }, ticks: { font: { size: 10 } }, }, }, }; export const buildDailyConversationsChartData = ( dailyConversations: IDailyConversation[] ) => { if (dailyConversations.length === 0) return null; let items = dailyConversations; if (items.length === 1) { const date = new Date(items[0].date); const prev = new Date(date); prev.setDate(prev.getDate() - 1); const next = new Date(date); next.setDate(next.getDate() + 1); const toISO = (d: Date) => d.toISOString().split('T')[0]; items = [ { date: toISO(prev), count: 0 }, items[0], { date: toISO(next), count: 0 }, ]; } return { labels: items.map(d => d.date), datasets: [ { label: 'Conversations', data: items.map(d => d.count), borderColor: RECOMAZE_COLORS.primary, backgroundColor: 'rgba(183,0,124,0.08)', fill: true, tension: 0.4, pointRadius: 3, pointBackgroundColor: RECOMAZE_COLORS.primary, }, ], }; };