"use client"; import { WeeklyCheckInStats } from "@fitai/shared"; import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/card"; import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer, } from "recharts"; interface WeeklyCheckInsCardProps { weeklyCheckIns: WeeklyCheckInStats[]; } export function WeeklyCheckInsCard({ weeklyCheckIns, }: WeeklyCheckInsCardProps) { const totalCheckIns = weeklyCheckIns.reduce( (sum, week) => sum + week.totalCheckIns, 0, ); const totalTimeMinutes = weeklyCheckIns.reduce( (sum, week) => sum + week.totalTimeMinutes, 0, ); const avgTimeMinutes = totalCheckIns > 0 ? Math.round(totalTimeMinutes / totalCheckIns) : 0; const chartData = weeklyCheckIns.map((week) => ({ week: week.weekStart, checkIns: week.totalCheckIns, timeMinutes: week.totalTimeMinutes, })); return ( Weekly Check-ins
{totalCheckIns}
Total Check-ins
{Math.floor(totalTimeMinutes / 60)}h {totalTimeMinutes % 60}m
Total Time
{avgTimeMinutes}m
Avg Duration
{chartData.length > 0 ? (
) : (
No check-in data available
)} {weeklyCheckIns.length > 0 && (

Weekly Breakdown

{weeklyCheckIns.slice(-4).map((week) => (
{week.weekStart} - {week.weekEnd} {week.totalCheckIns} check-ins • {week.totalTimeMinutes} min
))}
)}
); }