"use client"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Progress } from "@/components/ui/progress"; import { Badge } from "@/components/ui/badge"; import { Users, MessageSquare, Calendar, FolderOpen, Clock, CheckCircle, AlertTriangle, TrendingUp, Activity, Target } from "lucide-react"; import { formatDistanceToNow } from "date-fns"; interface WorkspaceStatsProps { tasks: any[]; projects: any[]; members: any[]; } export const WorkspaceProjectStats = ({ tasks, projects, members }: WorkspaceStatsProps) => { // Project distribution const tasksPerProject = projects.map(project => ({ name: project.name, taskCount: tasks.filter(task => task.projectId === project.id).length })); const unassignedToProject = tasks.filter(task => !task.projectId).length; const totalTasks = tasks.length; return ( Project Distribution

How tasks are distributed across your projects

{tasksPerProject .filter(project => project.taskCount > 0) .sort((a, b) => b.taskCount - a.taskCount) .slice(0, 5) .map((project) => (
{project.name}
0 ? (project.taskCount / totalTasks) * 100 : 0} className="w-16" /> {project.taskCount}
))} {unassignedToProject > 0 && (
Unassigned
0 ? (unassignedToProject / totalTasks) * 100 : 0} className="w-16" /> {unassignedToProject}
)} {totalTasks === 0 && (

No tasks found

)}
); }; export const WorkspaceDueDateStats = ({ tasks }: { tasks: any[] }) => { const now = new Date(); const nextWeek = new Date(now.getTime() + 7 * 24 * 60 * 60 * 1000); const overdueTasks = tasks.filter(task => task.dueDate && new Date(task.dueDate) < now && task.status !== 'DONE' ).length; const dueSoonTasks = tasks.filter(task => task.dueDate && new Date(task.dueDate) >= now && new Date(task.dueDate) <= nextWeek && task.status !== 'DONE' ).length; const noDueDateTasks = tasks.filter(task => !task.dueDate && task.status !== 'DONE').length; const activeTasks = tasks.filter(task => task.status !== 'DONE').length; return ( Due Date Analysis

Track deadlines and time management

{overdueTasks}

Overdue

{dueSoonTasks}

Due Soon

No Due Date
{noDueDateTasks} ({activeTasks > 0 ? Math.round((noDueDateTasks / activeTasks) * 100) : 0}%)
0 ? (noDueDateTasks / activeTasks) * 100 : 0} className="h-2" />
); }; interface WorkspaceCommunicationStatsProps { analytics: { totalComments: number; thisMonthComments: number; commentsDifference: number; tasksWithComments: number; totalTasksInWorkspace: number; avgCommentsPerTask: number; } | null; } export const WorkspaceCommunicationStats = ({ analytics }: WorkspaceCommunicationStatsProps) => { if (!analytics) { return ( Communication Activity

Track collaboration and engagement

Loading...

); } const { totalComments, thisMonthComments, commentsDifference, tasksWithComments, totalTasksInWorkspace, avgCommentsPerTask } = analytics; const tasksWithCommentsPercentage = totalTasksInWorkspace > 0 ? Math.round((tasksWithComments / totalTasksInWorkspace) * 100) : 0; return ( Communication Activity

Track collaboration and engagement

{totalComments}

Total Comments

{commentsDifference !== 0 && (
0 ? 'text-green-600' : 'text-red-600'}`}> {commentsDifference > 0 ? '+' : ''}{commentsDifference} this month
)}
{avgCommentsPerTask}

Avg per Task

Tasks with Comments
{tasksWithComments} ({tasksWithCommentsPercentage}%)
{totalComments === 0 && (

No comments yet. Start collaborating!

)}
); }; interface Epic { id: string; name: string; status: string; stats?: { totalTasks: number; completedTasks: number; progressPercentage: number; }; } interface EpicStatsProps { epics: Epic[]; } export const EpicStats = ({ epics }: EpicStatsProps) => { const totalEpics = epics.length; const completedEpics = epics.filter(epic => epic.status === "DONE").length; const inProgressEpics = epics.filter(epic => epic.status === "IN_PROGRESS").length; const overallProgress = totalEpics > 0 ? Math.round((completedEpics / totalEpics) * 100) : 0; const totalTasks = epics.reduce((sum, epic) => sum + (epic.stats?.totalTasks || 0), 0); const completedTasks = epics.reduce((sum, epic) => sum + (epic.stats?.completedTasks || 0), 0); const taskProgress = totalTasks > 0 ? Math.round((completedTasks / totalTasks) * 100) : 0; return ( Epic Progress
Epic Completion {completedEpics}/{totalEpics} epics
{overallProgress}% complete
Overall Task Progress {completedTasks}/{totalTasks} tasks
{taskProgress}% complete
{completedEpics} Done
{inProgressEpics} In Progress
{totalEpics - completedEpics - inProgressEpics} Remaining
); };