diff --git a/src/components/Project/Infrastructure/WorkArea.jsx b/src/components/Project/Infrastructure/WorkArea.jsx index cbe34dc5..69663630 100644 --- a/src/components/Project/Infrastructure/WorkArea.jsx +++ b/src/components/Project/Infrastructure/WorkArea.jsx @@ -6,11 +6,20 @@ 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"; const WorkArea = ({ workArea, floor, forBuilding }) => { const [workItems, setWorkItems] = useState([]); const dispatch = useDispatch(); - const [Project, setProject] = useState(); + const [ Project, setProject ] = useState(); + const {projectId} = useParams(); + + const ManageTasks = useHasUserPermission(MANAGE_TASK); + const ManageInfra = useHasUserPermission(MANAGE_PROJECT_INFRA); + const ManageAndAssignTak = useHasUserPermission( ASSIGN_REPORT_TASK ); + useEffect(() => { const project = getCachedData("projectInfo"); @@ -170,7 +179,7 @@ const WorkArea = ({ workArea, floor, forBuilding }) => { className="accordion-collapse collapse" aria-labelledby={`heading-${workArea.id}`} > -
| Progress | -- Actions - | + {( ManageInfra || ( !projectId && ManageAndAssignTak ) ) && ( ++ Actions + | + )}{hasWorkItem ? NewWorkItem?.workItem?.completedWork ?? - workItem?.completedWork ?? - "NA" + workItem?.completedWork ?? + "NA" : "NA"} /{" "} {hasWorkItem @@ -171,26 +171,28 @@ const WorkItem = ({ {hasWorkItem ? NewWorkItem?.workItem?.workCategoryMaster?.name || - workItem.workCategoryMaster?.name || - "NA" + workItem.workCategoryMaster?.name || + "NA" : "NA"} | - {hasWorkItem ? ( - `${NewWorkItem?.workItem?.completedWork ?? - workItem?.completedWork ?? - "0"}/${NewWorkItem?.workItem?.plannedWork ?? - workItem?.plannedWork ?? - "0"}` - ) : ( - "NA" - )} + {hasWorkItem + ? `${ + NewWorkItem?.workItem?.completedWork ?? + workItem?.completedWork ?? + "0" + }/${ + NewWorkItem?.workItem?.plannedWork ?? + workItem?.plannedWork ?? + "0" + }` + : "NA"} | {/* Progress Bar - always visible */} -+ |
{/* Actions - always visible */}
-
+
+ {/* Mobile (sm only): dropdown with icons */}
+
- {/* Desktop (md and up): inline icons */}
- |
+
- {!projectId &&
- ManageAndAssignTak &&
- PlannedWork !== CompletedWork && (
-
- )}
-
- {ManageInfra && (
- <>
-
-
- >
- )}
-
-
- {/* Mobile (sm only): dropdown with icons */}
-
-
-
-
+
+
+
+
|
+ )}
>
);
|---|