From 5e462a88f774f5c92b20ca28f381c55370afbb75 Mon Sep 17 00:00:00 2001 From: "kartik.sharma" Date: Fri, 23 May 2025 14:18:53 +0530 Subject: [PATCH] Move all the Projects Completion Status-related code from the Dashboard component into a new component named 'Projects Completion Status'. --- src/components/Dashboard/Dashboard.jsx | 28 ++------------ .../Dashboard/ProjectCompletionChart.jsx | 37 +++++++++++++++++++ 2 files changed, 40 insertions(+), 25 deletions(-) create mode 100644 src/components/Dashboard/ProjectCompletionChart.jsx diff --git a/src/components/Dashboard/Dashboard.jsx b/src/components/Dashboard/Dashboard.jsx index a352f5a5..29e3e755 100644 --- a/src/components/Dashboard/Dashboard.jsx +++ b/src/components/Dashboard/Dashboard.jsx @@ -8,6 +8,7 @@ import { useDashboardTeamsCardData, useDashboardTasksCardData, } from "../../hooks/useDashboard_Data"; +import ProjectCompletionChart from "./ProjectCompletionChart"; const Dashboard = () => { const { projects, loading } = useProjects(); @@ -55,15 +56,6 @@ const Dashboard = () => { (a, b) => new Date(a.date) - new Date(b.date) ); - // Bar chart logic - const projectNames = projects?.map((p) => p.name) || []; - const projectProgress = - projects?.map((p) => { - const completed = p.completedWork || 0; - const planned = p.plannedWork || 1; - const percent = (completed / planned) * 100; - return Math.min(Math.round(percent), 100); - }) || []; // Line chart data const lineChartSeries = [ @@ -170,22 +162,8 @@ const Dashboard = () => { {/* Bar Chart */} -
-
-
-
-
Projects
-

Projects Completion Status

-
-
-
- -
-
+
+
{/* Line Chart */} diff --git a/src/components/Dashboard/ProjectCompletionChart.jsx b/src/components/Dashboard/ProjectCompletionChart.jsx new file mode 100644 index 00000000..f0c85179 --- /dev/null +++ b/src/components/Dashboard/ProjectCompletionChart.jsx @@ -0,0 +1,37 @@ +import React from "react"; +import HorizontalBarChart from "../Charts/HorizontalBarChart"; +import { useProjects } from "../../hooks/useProjects"; + +const ProjectCompletionChart = () => { + const { projects, loading } = useProjects(); + + // Bar chart logic + const projectNames = projects?.map((p) => p.name) || []; + const projectProgress = + projects?.map((p) => { + const completed = p.completedWork || 0; + const planned = p.plannedWork || 1; + const percent = (completed / planned) * 100; + return Math.min(Math.round(percent), 100); + }) || []; + + return ( +
+
+
+
Projects
+

Projects Completion Status

+
+
+
+ +
+
+ ); +}; + +export default ProjectCompletionChart;