From eab23389ed4dbdf87a7abcb96b98591aaf5f9c8c Mon Sep 17 00:00:00 2001 From: Kartik Sharma Date: Mon, 13 Oct 2025 12:51:42 +0530 Subject: [PATCH] Correction in Projects Completion Status in this weidget data cannot be shown. --- src/components/Charts/HorizontalBarChart.jsx | 2 +- src/components/Dashboard/ProjectCompletionChart.jsx | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/Charts/HorizontalBarChart.jsx b/src/components/Charts/HorizontalBarChart.jsx index 82608da6..5a02c98f 100644 --- a/src/components/Charts/HorizontalBarChart.jsx +++ b/src/components/Charts/HorizontalBarChart.jsx @@ -23,7 +23,7 @@ const HorizontalBarChart = ({ if (loading) { return (
- Loading chart... + Loading chart... {/* Replace this with a skeleton or spinner if you prefer */}
); diff --git a/src/components/Dashboard/ProjectCompletionChart.jsx b/src/components/Dashboard/ProjectCompletionChart.jsx index 8ce4b13a..decf7918 100644 --- a/src/components/Dashboard/ProjectCompletionChart.jsx +++ b/src/components/Dashboard/ProjectCompletionChart.jsx @@ -3,7 +3,8 @@ import HorizontalBarChart from "../Charts/HorizontalBarChart"; import { useProjects } from "../../hooks/useProjects"; const ProjectCompletionChart = () => { - const { projects, loading } = useProjects(); + const { data: projects = [], isLoading: loading, isError, error } = useProjects(); + // Bar chart logic const projectNames = projects?.map((p) => p.name) || []; @@ -11,7 +12,7 @@ const ProjectCompletionChart = () => { projects?.map((p) => { const completed = p.completedWork || 0; const planned = p.plannedWork || 1; - const percent = (completed / planned) * 100; + const percent = planned ? (completed / planned) * 100 : 0; return Math.min(Math.round(percent), 100); }) || [];