'use client'; import { TrendingUp, Clock, Flame, BarChart3, PieChart as PieChartIcon, } from 'lucide-react'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { LineChart, Line, BarChart, Bar, PieChart, Pie, Cell, AreaChart, Area, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer, } from 'recharts'; interface TimeData { date: string; tasks: number; habits: number; time: number; } interface DomainData { name: string; value: number; color: string; } interface HabitData { name: string; streak: number; score: number; consistency: number; } const COLORS = ['#3b82f6', '#10b981', '#f59e0b', '#8b5cf6', '#ef4444', '#06b6d4']; const chartTooltipStyle = { backgroundColor: 'hsl(var(--card))', border: '1px solid hsl(var(--border))', borderRadius: '0.5rem', }; interface AnalyticsChartsProps { timeData: TimeData[]; domainData: DomainData[]; habitData: HabitData[]; activeTab: string; } export function AnalyticsCharts({ timeData, domainData, habitData, activeTab, }: AnalyticsChartsProps) { const hasActivity = timeData.some((day) => day.tasks > 0 || day.habits > 0 || day.time > 0); const hasRecentActivity = timeData.slice(-7).some((day) => day.tasks > 0 || day.habits > 0); const activitySummary = timeData .filter((day) => day.tasks > 0 || day.habits > 0 || day.time > 0) .map((day) => `${day.date}: ${day.tasks} tasks completed, ${day.habits} habits logged, ${day.time} minutes tracked.`) .join(' '); if (activeTab === 'trends') { return (
{/* Productivity trend */} {!hasActivity ? (

No completed tasks or habit logs in the last 30 days.

) : (
)}
{/* Time tracked trend */} {timeData.some((day) => day.time > 0) ? (
) : (

No time tracked in the last 30 days.

)}
); } if (activeTab === 'habits') { return (
{/* Habit streaks */} {habitData.length === 0 ? (

No habits tracked

) : (
`${habit.name}, ${habit.streak} days`).join('; ')}.`}>
)}
{/* Habit scores */} Habit Scores {habitData.length === 0 ? (

No habits tracked

) : (
{habitData.map((habit) => (
{habit.name} {habit.score}/100
))}
)}
); } if (activeTab === 'time') { return (
{/* Time by domain */} {domainData.length === 0 ? (

No time tracked

) : (

Time by domain: {domainData.map((domain) => `${domain.name}, ${domain.value} minutes`).join('; ')}.

`${name}: ${((percent || 0) * 100).toFixed(0)}%` } outerRadius={100} fill="#8884d8" dataKey="value" > {domainData.map((entry, index) => ( ))}
)}
{/* Daily breakdown */} {!hasRecentActivity ? (

No task or habit activity in the last 7 days.

) : (
)}
); } return null; }