'use client' import { Habit } from '@/lib/types' import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" import { useSettings } from '@/hooks/useSettings' import { d2s, getNow } from '@/lib/utils' import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer } from 'recharts' interface HabitStreakProps { habits: Habit[] } export default function HabitStreak({ habits }: HabitStreakProps) { const { settings } = useSettings() // Get the last 7 days of data const dates = Array.from({ length: 7 }, (_, i) => { const d = getNow({ timezone: settings.system.timezone }); return d2s({ dateTime: d.minus({ days: i }), format: 'yyyy-MM-dd' }); }).reverse() const completions = dates.map(date => { const completedCount = habits.reduce((count, habit) => { return count + (habit.completions.includes(date) ? 1 : 0); }, 0); return { date, completed: completedCount }; }); return ( Daily Habit Completion Streak
[`${value} habits`, 'Completed']} />
) }