diff --git a/src/components/dashboard/TasksStatPercent.jsx b/src/components/dashboard/TasksStatPercent.jsx index 92108da038c3163843f2290dc0c01c880ebfe356..b1ec843a44bebd76a4d14abb1632a9844bebeb6c 100644 --- a/src/components/dashboard/TasksStatPercent.jsx +++ b/src/components/dashboard/TasksStatPercent.jsx @@ -1,6 +1,12 @@ -import React from 'react'; +import React, { useContext } from "react"; +import { TasksContext } from "@services/Context"; -const TasksStatPercent = ({ totalTasks, completedTasks }) => { +const TasksStatPercent = () => { + const { tasks } = useContext(TasksContext); + + const totalTasks = tasks.length; + const completedTasks = tasks.filter(task => task.isCompleted).length; + const radius = 50; const circumference = 2 * Math.PI * radius; const completedPercentage = totalTasks === 0 ? 0 : Math.round((completedTasks / totalTasks) * 100);