diff --git a/src/components/Charts/ProgressDonutChart.jsx b/src/components/Charts/ProgressDonutChart.jsx new file mode 100644 index 00000000..04cd8a22 --- /dev/null +++ b/src/components/Charts/ProgressDonutChart.jsx @@ -0,0 +1,79 @@ +import React from "react"; +import ReactApexChart from "react-apexcharts"; + +const ProgressDonutChart = ({ completed = 0, planned = 1 }) => { + const percentage = planned > 0 ? Math.round((completed / planned) * 100) : 0; + + const options = { + chart: { + height: 10, + type: "radialBar", + toolbar: { show: false }, + }, + plotOptions: { + radialBar: { + startAngle: 0, + endAngle: 360, + hollow: { + margin: 0, + size: "10%", + background: "#fff", + dropShadow: { + enabled: true, + top: 0, + left: 0, + blur: 3, + opacity: 0.45, + }, + }, + track: { + background: "#f5f5f5", + strokeWidth: "10%", + dropShadow: { enabled: false }, + }, + dataLabels: { + show: true, + name: { + offsetY: -10, + color: "#888", + fontSize: "14px", + }, + value: { + formatter: (val) => `${val}%`, + color: "#111", + fontSize: "11px", + show: true, + }, + }, + }, + }, + fill: { + type: "gradient", + gradient: { + shade: "dark", + type: "horizontal", + shadeIntensity: 0.5, + gradientToColors: ["#ABE5A1"], + opacityFrom: 1, + opacityTo: 1, + stops: [0, 100], + }, + }, + stroke: { + lineCap: "round", + }, + }; + + return ( +
+ +
+ ); +}; + +export default ProgressDonutChart; diff --git a/src/components/Project/Infrastructure/Floor.jsx b/src/components/Project/Infrastructure/Floor.jsx index 316391dd..5288ce16 100644 --- a/src/components/Project/Infrastructure/Floor.jsx +++ b/src/components/Project/Infrastructure/Floor.jsx @@ -13,10 +13,10 @@ const Floor = ({ floor, workAreas, forBuilding }) => { /> )) ) : ( - + -
- {/*
+
+ {/*
*/}
-
+
{" "} Floor:  @@ -34,6 +34,13 @@ const Floor = ({ floor, workAreas, forBuilding }) => { {floor.floorName}
+
+ {" "} + + Work Area:  + {" "} + Not Available +
diff --git a/src/components/Project/Infrastructure/InfraTable.jsx b/src/components/Project/Infrastructure/InfraTable.jsx index 30410c6c..4b1e863f 100644 --- a/src/components/Project/Infrastructure/InfraTable.jsx +++ b/src/components/Project/Infrastructure/InfraTable.jsx @@ -68,7 +68,6 @@ const InfraTable = ({ buildings }) => { showToast("Failed to save floor", "error"); } } catch (err) { - showToast("Error occurred while saving floor", "error"); } }; @@ -95,14 +94,14 @@ const InfraTable = ({ buildings }) => { No floors have been added yet. Start by adding floors to manage this building.

- + */}
diff --git a/src/components/Project/Infrastructure/WorkArea.jsx b/src/components/Project/Infrastructure/WorkArea.jsx index 69663630..d9fc3580 100644 --- a/src/components/Project/Infrastructure/WorkArea.jsx +++ b/src/components/Project/Infrastructure/WorkArea.jsx @@ -6,20 +6,46 @@ import { useDispatch } from "react-redux"; import { refreshData } from "../../../slices/localVariablesSlice"; import ProjectRepository from "../../../repositories/ProjectRepository"; import showToast from "../../../services/toastService"; -import {useHasUserPermission} from "../../../hooks/useHasUserPermission"; -import {ASSIGN_REPORT_TASK, MANAGE_PROJECT_INFRA, MANAGE_TASK} from "../../../utils/constants"; -import {useParams} from "react-router-dom"; +import { useHasUserPermission } from "../../../hooks/useHasUserPermission"; +import { + ASSIGN_REPORT_TASK, + MANAGE_PROJECT_INFRA, + MANAGE_TASK, +} from "../../../utils/constants"; +import { useParams } from "react-router-dom"; +import ProgressDonutChart from "../../Charts/ProgressDonutChart"; +import ProgressBar from "../../common/ProgressBar"; +import { componentsToColor } from "pdf-lib"; const WorkArea = ({ workArea, floor, forBuilding }) => { const [workItems, setWorkItems] = useState([]); const dispatch = useDispatch(); - const [ Project, setProject ] = useState(); - const {projectId} = useParams(); - - const ManageTasks = useHasUserPermission(MANAGE_TASK); - const ManageInfra = useHasUserPermission(MANAGE_PROJECT_INFRA); - const ManageAndAssignTak = useHasUserPermission( ASSIGN_REPORT_TASK ); - + const [Project, setProject] = useState(); + const { projectId } = useParams(); + + const ManageTasks = useHasUserPermission(MANAGE_TASK); + const ManageInfra = useHasUserPermission(MANAGE_PROJECT_INFRA); + const ManageAndAssignTak = useHasUserPermission(ASSIGN_REPORT_TASK); + + const [workAreaStatus, setWorkAreaStatus] = useState({ + completed: 0, + planned: 100, + }); + + useEffect(() => { + const totalCompleted = workItems.reduce( + (sum, i) => sum + (i.workItem?.completedWork || 0), + 0 + ); + const totalPlanned = workItems.reduce( + (sum, i) => sum + (i.workItem?.plannedWork || 0), + 0 + ); + const percent = + totalPlanned > 0 ? (totalCompleted / totalPlanned) * 100 : 0; + //setPercentComplete(Math.min(percent, 100)); // cap at 100% + setWorkAreaStatus({ completed: totalCompleted, planned: totalPlanned }); + }, [workItems]); useEffect(() => { const project = getCachedData("projectInfo"); @@ -153,21 +179,32 @@ const WorkArea = ({ workArea, floor, forBuilding }) => { }} > -
-
- Floor:  - +
+
+ + Floor: + + {floor.floorName}
-
+
- Work Area:  + Work Area: - + {workArea.areaName}
+ {workArea?.workItems?.length > 0 && ( +
+ +
+ )}

@@ -198,7 +235,8 @@ const WorkArea = ({ workArea, floor, forBuilding }) => { Progress - {( ManageInfra || ( !projectId && ManageAndAssignTak ) ) && ( + {(ManageInfra || + (!projectId && ManageAndAssignTak)) && ( Actions