()
| 3 | import { useSelector } from "react-redux"; |
| 4 | |
| 5 | export default function StatsGrid() { |
| 6 | const currentWorkspace = useSelector( |
| 7 | (state) => state?.workspace?.currentWorkspace || null |
| 8 | ); |
| 9 | |
| 10 | const [stats, setStats] = useState({ |
| 11 | totalProjects: 0, |
| 12 | activeProjects: 0, |
| 13 | completedProjects: 0, |
| 14 | myTasks: 0, |
| 15 | overdueIssues: 0, |
| 16 | }); |
| 17 | |
| 18 | const statCards = [ |
| 19 | { |
| 20 | icon: FolderOpen, |
| 21 | title: "Total Projects", |
| 22 | value: stats.totalProjects, |
| 23 | subtitle: `projects in ${currentWorkspace?.name}`, |
| 24 | bgColor: "bg-blue-500/10", |
| 25 | textColor: "text-blue-500", |
| 26 | }, |
| 27 | { |
| 28 | icon: CheckCircle, |
| 29 | title: "Completed Projects", |
| 30 | value: stats.completedProjects, |
| 31 | subtitle: `of ${stats.totalProjects} total`, |
| 32 | bgColor: "bg-emerald-500/10", |
| 33 | textColor: "text-emerald-500", |
| 34 | }, |
| 35 | { |
| 36 | icon: Users, |
| 37 | title: "My Tasks", |
| 38 | value: stats.myTasks, |
| 39 | subtitle: "assigned to me", |
| 40 | bgColor: "bg-purple-500/10", |
| 41 | textColor: "text-purple-500", |
| 42 | }, |
| 43 | { |
| 44 | icon: AlertTriangle, |
| 45 | title: "Overdue", |
| 46 | value: stats.overdueIssues, |
| 47 | subtitle: "need attention", |
| 48 | bgColor: "bg-amber-500/10", |
| 49 | textColor: "text-amber-500", |
| 50 | }, |
| 51 | ]; |
| 52 | |
| 53 | useEffect(() => { |
| 54 | if (currentWorkspace) { |
| 55 | setStats({ |
| 56 | totalProjects: currentWorkspace.projects.length, |
| 57 | activeProjects: currentWorkspace.projects.filter( |
| 58 | (p) => p.status !== "CANCELLED" && p.status !== "COMPLETED" |
| 59 | ).length, |
| 60 | completedProjects: currentWorkspace.projects |
| 61 | .filter((p) => p.status === "COMPLETED") |
| 62 | .reduce((acc, project) => acc + project.tasks.length, 0), |
nothing calls this directly
no outgoing calls
no test coverage detected