From 41f3628d45fccb001c8dbfd0978b895002b466c3 Mon Sep 17 00:00:00 2001
From: Vikas Nale
Date: Fri, 13 Jun 2025 09:39:27 +0530
Subject: [PATCH] For project progress widget set default selection 15W
---
.../Dashboard/ProjectProgressChart.jsx | 54 ++++++++++++-------
1 file changed, 36 insertions(+), 18 deletions(-)
diff --git a/src/components/Dashboard/ProjectProgressChart.jsx b/src/components/Dashboard/ProjectProgressChart.jsx
index 15f19582..afc5e11d 100644
--- a/src/components/Dashboard/ProjectProgressChart.jsx
+++ b/src/components/Dashboard/ProjectProgressChart.jsx
@@ -5,21 +5,31 @@ import { useDashboard_Data } from "../../hooks/useDashboard_Data";
import { useSelector } from "react-redux";
const ProjectProgressChart = () => {
- const selectedProject = useSelector((store) => store.localVariables.projectId);
+ const selectedProject = useSelector(
+ (store) => store.localVariables.projectId
+ );
const { projects } = useProjects();
- const [range, setRange] = useState("1W");
+ const [range, setRange] = useState("15D");
const [showAllEmployees, setShowAllEmployees] = useState(false);
const getDaysFromRange = (range) => {
switch (range) {
- case "1D": return 1;
- case "1W": return 7;
- case "15D": return 15;
- case "1M": return 30;
- case "3M": return 90;
- case "1Y": return 365;
- case "5Y": return 1825;
- default: return 7;
+ case "1D":
+ return 1;
+ case "1W":
+ return 7;
+ case "15D":
+ return 15;
+ case "1M":
+ return 30;
+ case "3M":
+ return 90;
+ case "1Y":
+ return 365;
+ case "5Y":
+ return 1825;
+ default:
+ return 7;
}
};
@@ -27,9 +37,8 @@ const ProjectProgressChart = () => {
const today = new Date();
const FromDate = today.toLocaleDateString("en-CA");
- const projectId = showAllEmployees || !selectedProject?.trim()
- ? null
- : selectedProject;
+ const projectId =
+ showAllEmployees || !selectedProject?.trim() ? null : selectedProject;
const { dashboard_data, loading: isLineChartLoading } = useDashboard_Data({
days,
@@ -53,7 +62,10 @@ const ProjectProgressChart = () => {
];
const lineChartCategories = sortedDashboardData.map((d) =>
- new Date(d.date).toLocaleDateString("en-US", { month: "short", day: "numeric" })
+ new Date(d.date).toLocaleDateString("en-US", {
+ month: "short",
+ day: "numeric",
+ })
);
const lineChartCategoriesDates = sortedDashboardData.map((d) =>
new Date(d.date).toLocaleDateString("en-US", {
@@ -89,7 +101,10 @@ const ProjectProgressChart = () => {
checked={showAllEmployees}
onChange={(e) => setShowAllEmployees(e.target.checked)}
/>
-
)}
-
+
{/* Row 2: Time Range Buttons */}
{["1D", "1W", "15D", "1M", "3M", "1Y", "5Y"].map((key) => (