import React from 'react'; import type { IAgentDashboardData } from '../../service/agent-analytics/agent-analytics.interface'; import KPICard from './KPICard'; import Section from './Section'; import HBar from './HBar'; import ChartCanvas from './ChartCanvas'; import EmptyState from './EmptyState'; import ErrorBanner from './ErrorBanner'; import { CardSkeleton, ChartSkeleton } from './CardSkeleton'; import { formatNumber, formatPercentage, RECOMAZE_COLORS } from './helpers'; import InfoTooltip from './InfoTooltip'; import { OVERVIEW_LINE_CHART_OPTIONS, buildDailyConversationsChartData, } from './overviewTab.utils'; // Native SVG Icons to replace react-icons const IconChat = ({ className = '' }) => ( ); const IconUsers = ({ className = '' }) => ( ); const IconPercent = ({ className = '' }) => ( ); const IconThumbUp = ({ className = '' }) => ( ); const IconCursorClick = ({ className = '' }) => ( ); const IconCart = ({ className = '' }) => ( ); interface OverviewTabProps { data: IAgentDashboardData | null; loading: boolean; error: string | null; onRetry: () => void; } const OverviewTab = ({ data, loading, error, onRetry, }: OverviewTabProps): JSX.Element => { if (loading) { return (
{Array.from({ length: 6 }).map((_, i) => ( ))}
); } if (error) return ; if (!data || !data.overview) return ; const o = data.overview; const t = data.overview_trends || {}; const f = data.funnel || ({} as IAgentDashboardData['funnel']); const pf = f.product_funnel || { products_shown: 0, products_clicked: 0, products_carted: 0, }; const ep = data.engagement_patterns || ({} as IAgentDashboardData['engagement_patterns']); const dailyData = ep.daily_conversations || []; const lineData = buildDailyConversationsChartData(dailyData); const funnelMax = Math.max(f.total_conversations || 0, 1); const pfMax = Math.max(pf.products_shown || 0, 1); return (
{lineData ? (
) : ( )}

Product Funnel

Avg Messages/Conv

{formatNumber(o.avg_messages_per_conversation, 1)}

Avg Duration

{formatNumber(o.avg_duration_minutes, 1)}{' '} min

High Intent Conv.

{formatNumber(o.high_intent_conversations)}

{formatPercentage(o.high_intent_rate)} of total

Returning Rate

{formatPercentage(o.returning_rate)}

{formatNumber(o.returning_visitors)} returning

); }; export default OverviewTab;