diff --git a/src/components/Project/Infrastructure/InfraTable.jsx b/src/components/Project/Infrastructure/InfraTable.jsx index fb484f6e..77c6f905 100644 --- a/src/components/Project/Infrastructure/InfraTable.jsx +++ b/src/components/Project/Infrastructure/InfraTable.jsx @@ -143,7 +143,7 @@ const InfraTable = ({ buildings, projectId}) => { // }, [handler]); return ( -
+
{projectBuilding && projectBuilding.length > 0 && ( diff --git a/src/components/Project/ProjectInfra.jsx b/src/components/Project/ProjectInfra.jsx index 38c05567..0669c136 100644 --- a/src/components/Project/ProjectInfra.jsx +++ b/src/components/Project/ProjectInfra.jsx @@ -17,22 +17,21 @@ import { getCachedData, useSelectedProject, } from "../../slices/apiDataManager"; -import { useProjectDetails, useProjectInfra } from "../../hooks/useProjects"; +import { useProjectAssignedServices, useProjectDetails, useProjectInfra } from "../../hooks/useProjects"; import { useDispatch, useSelector } from "react-redux"; import { refreshData } from "../../slices/localVariablesSlice"; import eventBus from "../../services/eventBus"; -import {useParams} from "react-router-dom"; +import { useParams } from "react-router-dom"; import GlobalModel from "../common/GlobalModel"; -const ProjectInfra = ( {data, onDataChange, eachSiteEngineer} ) => -{ +const ProjectInfra = ({ data, onDataChange, eachSiteEngineer }) => { // const projectId = useSelector((store)=>store.localVariables.projectId) const projectId = useSelectedProject(); const reloadedData = useSelector((store) => store.localVariables.reload); - const [ expandedBuildings, setExpandedBuildings ] = useState( [] ); - const {projectInfra,isLoading,error} = useProjectInfra(projectId) + const [expandedBuildings, setExpandedBuildings] = useState([]); + const { projectInfra, isLoading, error } = useProjectInfra(projectId) const { projects_Details, refetch, loading } = useProjectDetails(data?.id); - const [ project, setProject ] = useState( projects_Details ); + const [project, setProject] = useState(projects_Details); const ManageInfra = useHasUserPermission(MANAGE_PROJECT_INFRA); const ManageTask = useHasUserPermission(MANAGE_TASK) const [showModalFloor, setshowModalFloor] = useState(false); @@ -40,47 +39,46 @@ const ProjectInfra = ( {data, onDataChange, eachSiteEngineer} ) => const [showModalTask, setshowModalTask] = useState(false); const [showModalBuilding, setshowModalBuilding] = useState(false); const dispatch = useDispatch(); + const { data: assignedServices, isLoading: servicesLoading } = useProjectAssignedServices(projectId); + + const [selectedService, setSelectedService] = useState(""); + const handleServiceChange = (e) => { + setSelectedService(e.target.value); + }; useEffect(() => { setProject(projectInfra); }, [data, projects_Details]); - // useEffect(() => { - // if (reloadedData) { - // refetch(); - // dispatch(refreshData(false)); - // } - // }, [reloadedData]); - const signalRHandler = (response) => { setProject(response); } return ( <> - {showModalBuilding && setshowModalBuilding( false )}> + {showModalBuilding && setshowModalBuilding(false)}> setshowModalBuilding( false )} + onClose={() => setshowModalBuilding(false)} /> - } - {showModalFloor && setshowModalFloor(false)}> + } + {showModalFloor && setshowModalFloor(false)}> setshowModalFloor(false)} - /> + project={projectInfra} + onClose={() => setshowModalFloor(false)} + /> } - {showModalWorkArea && setshowModalWorkArea(false)} > - setshowModalWorkArea(false)} - /> + {showModalWorkArea && setshowModalWorkArea(false)} > + setshowModalWorkArea(false)} + /> } - {showModalTask && ( setshowModalTask(false)}> + {showModalTask && ( setshowModalTask(false)}> setshowModalTask(false)} - /> + project={projectInfra} + onClose={() => setshowModalTask(false)} + /> )}
@@ -88,38 +86,73 @@ const ProjectInfra = ( {data, onDataChange, eachSiteEngineer} ) =>
- {ManageInfra && (<> - - - )} - + {servicesLoading ? ( + + ) : assignedServices?.length > 1 ? ( + + ) : ( +
+ {assignedServices?.length === 1 + ?
{ assignedServices[0].name}
+ : "No service available"} +
+ )} +
+ {/* Buttons Section (aligned to right) */} +
+ {ManageInfra && ( + <> + + + )} + {(ManageTask || ManageInfra) && (