For project progress widget set default selection 15W

This commit is contained in:
Vikas Nale 2025-06-13 09:39:27 +05:30
parent 31a9f55b63
commit 41f3628d45

View File

@ -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)}
/>
<label className="form-check-label ms-2" htmlFor="showAllEmployees">
<label
className="form-check-label ms-2"
htmlFor="showAllEmployees"
>
All Projects
</label>
</div>
@ -99,15 +114,18 @@ const ProjectProgressChart = () => {
</p>
)}
</div>
</div>
</div>
{/* Row 2: Time Range Buttons */}
<div className="d-flex flex-wrap mt-2">
{["1D", "1W", "15D", "1M", "3M", "1Y", "5Y"].map((key) => (
<button
key={key}
className={`border-0 bg-transparent px-2 py-1 text-sm rounded ${range === key ? "border-bottom border-primary text-primary" : "text-muted"
}`}
className={`border-0 bg-transparent px-2 py-1 text-sm rounded ${
range === key
? "border-bottom border-primary text-primary"
: "text-muted"
}`}
style={{ cursor: "pointer", transition: "all 0.2s ease" }}
onClick={() => setRange(key)}
>