-
+
- {/* Accordion Header */}
-
+
- {/* Accordion Body */}
- {workItems && workItems.length > 0 && (
-
-
+
+
+ {isLoading ? (
+ Loading activities...
+ ) : ProjectTaskList?.length > 0 ? (
-
- Activity
- |
+ Activity |
Status
|
@@ -241,11 +181,8 @@ const WorkArea = ( {workArea, floor, forBuilding} ) =>
Today's Planned
|
-
- Progress
- |
- {(ManageInfra ||
- (!projectId && ManageAndAssignTak)) && (
+ Progress |
+ {(ManageInfra || (!projectId && ManageAndAssignTak)) && (
Actions
|
@@ -253,7 +190,7 @@ const WorkArea = ( {workArea, floor, forBuilding} ) =>
- {workArea.workItems.map((workItem) => (
+ {ProjectTaskList.map((workItem) => (
))}
-
+ ) : (
+
+ No activities available for this work area.
+
+ )}
- )}
+
|
@@ -275,4 +216,5 @@ const WorkArea = ( {workArea, floor, forBuilding} ) =>
);
};
+
export default WorkArea;
diff --git a/src/components/Project/Infrastructure/WorkItem.jsx b/src/components/Project/Infrastructure/WorkItem.jsx
index 101ca073..e24498c1 100644
--- a/src/components/Project/Infrastructure/WorkItem.jsx
+++ b/src/components/Project/Infrastructure/WorkItem.jsx
@@ -79,8 +79,7 @@ const WorkItem = ({
tooltipTriggerList.forEach((el) => new bootstrap.Tooltip(el));
}, []);
- const showModal1 = () => setShowModal(true);
- const closeModal1 = () => setShowModal(false);
+
const showModalDelete = () => setShowModal2(true);
const closeModalDelete = () => setShowModal2(false);
@@ -105,21 +104,15 @@ const WorkItem = ({
)}
{showModal && (
-
+ setShowModal(false)}>
setShowModal(false)}
/>
-
+
)}
{showModal2 && (
@@ -169,7 +162,7 @@ const WorkItem = ({
: "NA"}
- {/* Category - visible on medium and above */}
+
{hasWorkItem
@@ -255,7 +248,7 @@ const WorkItem = ({
setShowModal(true)}
role="button"
>
setShowModal(true) }
>
Edit
diff --git a/src/components/Project/ProjectInfra.jsx b/src/components/Project/ProjectInfra.jsx
index f7ea4acd..1590baf1 100644
--- a/src/components/Project/ProjectInfra.jsx
+++ b/src/components/Project/ProjectInfra.jsx
@@ -17,42 +17,39 @@ import {
clearCacheKey,
getCachedData,
} from "../../slices/apiDataManager";
-import { useProjectDetails } from "../../hooks/useProjects";
+import { 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 GlobalModel from "../common/GlobalModel";
-const ProjectInfra = ({ data, onDataChange, eachSiteEngineer }) => {
+const ProjectInfra = ( {data, onDataChange, eachSiteEngineer} ) =>
+{
+ const {projectId} = useParams()
const reloadedData = useSelector((store) => store.localVariables.reload);
- const [expandedBuildings, setExpandedBuildings] = useState([]);
+ 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 [modalConfig, setModalConfig] = useState({ type: null, data: null });
const [isModalOpen, setIsModalOpen] = useState(false);
const ManageInfra = useHasUserPermission(MANAGE_PROJECT_INFRA);
-
const [isBuildingModalOpen, setIsBuildingModalOpen] = useState(false);
- const [isFloorModalOpen, setIsFloorModalOpen] = useState(false);
+ const [showModalFloor, setshowModalFloor] = useState(false);
const [isWorkAreaModelOpen, setIsWorkAreaModalOpen] = useState(false);
const [isTaskModelOpen, setIsTaskModalOpen] = useState(false);
const [isAssignRoleModal, setIsAssingRoleModal] = useState(false);
const [isCreateModalOpen, setIsCreateModalOpen] = useState(false);
const [clearFormTrigger, setClearFormTrigger] = useState(false);
const [CurrentBuilding, setCurrentBuilding] = useState("");
- const [showModal, setShowModal] = useState(false);
+ const [showModalBuilding, setshowModalBuilding] = useState(false);
const dispatch = useDispatch();
useEffect(() => {
- setProject(projects_Details);
+ setProject(projectInfra);
}, [data, projects_Details]);
- const openFloorModel = (projectData) => {
- setIsFloorModalOpen(true);
- };
- const closeFloorModel = () => {
- setIsFloorModalOpen(false);
- };
-
const openAssignModel = (assignData) => {
setCurrentBuilding(assignData);
setIsAssingRoleModal(true);
@@ -65,29 +62,6 @@ const ProjectInfra = ({ data, onDataChange, eachSiteEngineer }) => {
setIsBuildingModalOpen(false);
};
- const handleBuildingModelFormSubmit = (buildingmodel) => {
- if (buildingmodel.id == "" || buildingmodel.id == 0)
- delete buildingmodel.id;
- let data = [
- {
- building: buildingmodel,
- floor: null,
- workArea: null,
- },
- ];
- submitData(data);
- };
- const handleFloorModelFormSubmit = (updatedFloor) => {
- if (updatedFloor.id == "") delete updatedFloor.id;
- submitData([
- {
- building: null,
- floor: updatedFloor,
- workArea: null,
- },
- ]);
- };
-
const openWorkAreaModel = (projectData) => {
setIsWorkAreaModalOpen(true);
};
@@ -322,23 +296,20 @@ const ProjectInfra = ({ data, onDataChange, eachSiteEngineer }) => {
const modalElement = document.getElementById("building-model");
if (modalElement) {
- modalElement.classList.remove("show"); // Remove modal visibility class
- modalElement.style.display = "none"; // Hide the modal element
+ modalElement.classList.remove("show");
+ modalElement.style.display = "none";
}
- document.body.classList.remove("modal-open"); // Remove modal-open class from body
+ document.body.classList.remove("modal-open");
- // Remove the modal backdrop
const backdropElement = document.querySelector(".modal-backdrop");
if (backdropElement) {
- backdropElement.classList.remove("modal-backdrop"); // Remove backdrop class
- backdropElement.style.display = "none"; // Hide the backdrop element
+ backdropElement.classList.remove("modal-backdrop");
+ backdropElement.style.display = "none";
}
document.body.style.overflow = "auto";
};
- const handleShow = () => setShowModal(true);
- const handleClose = () => setShowModal(false);
useEffect(() => {
if (reloadedData) {
refetch();
@@ -352,39 +323,21 @@ const ProjectInfra = ({ data, onDataChange, eachSiteEngineer }) => {
return (
<>
-
+
+ {showModalBuilding && setshowModalBuilding( false )}>
setClearFormTrigger(false)}
- >
-
- {isFloorModalOpen && (
-
- setClearFormTrigger(false)}
+ project={projectInfra}
+ onClose={() => setshowModalBuilding( false )}
+ />
+ }
+ {showModalFloor && setshowModalFloor(false)}>
+ setshowModalFloor(false)}
/>
-
- )}
+ }
+
+
{isWorkAreaModelOpen && (
{
setClearFormTrigger(false)}
/>
@@ -418,7 +370,7 @@ const ProjectInfra = ({ data, onDataChange, eachSiteEngineer }) => {
project={project}
onClose={closeTaskModel}
onSubmit={handleTaskModelFormSubmit}
- clearTrigger={clearFormTrigger}
+
onClearComplete={() => setClearFormTrigger(false)}
/>
@@ -441,15 +393,15 @@ const ProjectInfra = ({ data, onDataChange, eachSiteEngineer }) => {
- {/* Modal Component */}
{modalConfig?.type === "assignRole" && }
diff --git a/src/components/Project/ProjectNav.jsx b/src/components/Project/ProjectNav.jsx
index 444c6f03..9b266a9b 100644
--- a/src/components/Project/ProjectNav.jsx
+++ b/src/components/Project/ProjectNav.jsx
@@ -17,7 +17,7 @@ const ProjectNav = ({ onPillClick, activePill }) => {
className={`nav-link ${activePill === "profile" ? "active" : ""}`}
href="#"
onClick={(e) => {
- e.preventDefault(); // Prevent page reload
+ e.preventDefault();
onPillClick("profile");
}}
>
@@ -29,7 +29,7 @@ const ProjectNav = ({ onPillClick, activePill }) => {
className={`nav-link ${activePill === "teams" ? "active" : ""}`}
href="#"
onClick={(e) => {
- e.preventDefault(); // Prevent page reload
+ e.preventDefault();
onPillClick("teams");
}}
>
@@ -41,27 +41,14 @@ const ProjectNav = ({ onPillClick, activePill }) => {
className={`nav-link ${activePill === "infra" ? "active" : ""}`}
href="#"
onClick={(e) => {
- e.preventDefault(); // Prevent page reload
+ e.preventDefault();
onPillClick("infra");
}}
>
Infrastructure
- {/*
- {
- e.preventDefault(); // Prevent page reload
- onPillClick("workplan");
- }}
- >
- Work Plan
-
- */}
+
-{
-const {projects} = useProjects()
+const ProjectOverview = ({project}) =>{
+ const {projects} = useProjects()
+
const project_detail = projects.find( ( pro ) => pro.id == project )
return (
diff --git a/src/components/Project/Teams.jsx b/src/components/Project/Teams.jsx
index 6a772b11..00295f51 100644
--- a/src/components/Project/Teams.jsx
+++ b/src/components/Project/Teams.jsx
@@ -1,6 +1,6 @@
import React, { useState, useEffect, useCallback } from "react";
import MapUsers from "./MapUsers";
-import { Link, NavLink, useNavigate } from "react-router-dom";
+import { Link, NavLink, useNavigate, useParams } from "react-router-dom";
import showToast from "../../services/toastService";
import Avatar from "../common/Avatar";
@@ -16,7 +16,9 @@ import ConfirmModal from "../common/ConfirmModal";
import eventBus from "../../services/eventBus";
import {useEmployeesByProjectAllocated, useManageProjectAllocation} from "../../hooks/useProjects";
-const Teams = ({ project }) => {
+const Teams = () =>
+{
+ const {projectId} = useParams()
const dispatch = useDispatch();
const { data, loading } = useMaster();
@@ -35,7 +37,7 @@ const Teams = ({ project }) => {
const HasAssignUserPermission = useHasUserPermission( ASSIGN_TO_PROJECT );
const [ IsDeleteModal, setIsDeleteModal ] = useState( false )
- const {projectEmployees, loading:employeeLodaing, refetch} = useEmployeesByProjectAllocated( project.id )
+ const {projectEmployees, loading:employeeLodaing, refetch} = useEmployeesByProjectAllocated( projectId )
const {
mutate: submitAllocations,
isPending,
@@ -216,11 +218,11 @@ const {
const handler = useCallback(
(msg) => {
- if (msg.projectIds.some((item) => item === project.id)) {
+ if (msg.projectIds.some((item) => item === projectId)) {
refetch();
}
},
- [project.id, refetch]
+ [projectId, refetch]
);
useEffect(() => {
@@ -251,7 +253,7 @@ const {
aria-hidden="true"
>
const res = await ProjectRepository.getProjectAllocation( selectedProject );
return res.data || res
},
- enabled:!!selectedProject
+ enabled: !!selectedProject,
+ onError: ( error ) =>
+ {
+ showToast(error.message || "Error while Fetching project Allocated Employees", "error");
+ }
} )
return {
@@ -256,7 +260,11 @@ export const useProjectDetails = ( projectId,isAuto = true ) =>
const res = await ProjectRepository.getProjectByprojectId( projectId );
return res.data || res;
},
- enabled:!!projectId && isAuto
+ enabled: !!projectId && isAuto,
+ onError: ( error ) =>
+ {
+ showToast(error.message || "Error while Fetching project Details", "error");
+ }
} )
return { projects_Details, loading:isLoading, error, refetch };
}
@@ -270,7 +278,11 @@ export const useProjectsByEmployee = (employeeId) =>
const res = await ProjectRepository.getProjectsByEmployee( employeeId );
return res.data || res;
},
- enabled: !!employeeId
+ enabled: !!employeeId,
+ onError: ( error ) =>
+ {
+ showToast(error.message || "Error while Fetching project Employee", "error");
+ }
})
return {projectList, loading:isLoading,error,refetch }
}
@@ -284,11 +296,55 @@ export const useProjectName = () =>
const res = await ProjectRepository.projectNameList();
return res.data || res;
},
+ onError: ( error ) =>
+ {
+ showToast(error.message || "Error while Fetching project Name", "error");
+ }
} )
return {projectNames:data,loading:isLoading,Error:error,refetch}
}
+
+export const useProjectInfra = (projectId) => {
+ const {
+ data: projectInfra,
+ isLoading,
+ error,
+ } = useQuery({
+ queryKey: ["ProjectInfra", projectId],
+ queryFn: async () => {
+ const res = await ProjectRepository.getProjectInfraByproject(projectId);
+ return res.data;
+ },
+ enabled: !!projectId ,
+ onError: (error) => {
+ showToast(error.message || "Error while fetching project infra", "error");
+ },
+ });
+
+ return { projectInfra, isLoading, error };
+};
+
+
+export const useProjectTasks = (workAreaId,IsExpandedArea=false) =>
+{
+ const { data:ProjectTaskList,isLoading,error } = useQuery( {
+ queryKey: [ "WorkItems",workAreaId ],
+ queryFn: async () =>
+ {
+ const res = await ProjectRepository.getProjectTasksByWorkArea(workAreaId);
+ return res.data;
+ },
+ enabled: !!workAreaId && !!IsExpandedArea,
+ onError: ( error ) =>
+ {
+ showToast(error.message || "Error while Fetching project Tasks", "error");
+ }
+ } )
+ return {ProjectTaskList,isLoading,error}
+}
+
// -- Mutation-------------------------------
@@ -371,21 +427,22 @@ export const useUpdateProject = ({ onSuccessCallback }) => {
};
-export const useManageProjectInfra = () => {
+export const useManageProjectInfra = ( {onSuccessCallback} ) =>
+{
+ const queryClient = useQueryClient();
return useMutation({
- mutationFn: async ({infraObject,projectId}) => {
+ mutationFn: async ( {infraObject, projectId} ) =>
+ {
return await ProjectRepository.manageProjectInfra(infraObject);
},
- onSuccess: ( response, variables ) =>
+ onSuccess: ( data, variables ) =>
{
- const { projectId } = variables;
- showToast( "Details updated successfully.", "success" );
-
- queryClient.invalidateQueries(["projectinfo", projectId]);
-
+ const { projectId } = variables;
+ queryClient.invalidateQueries(["ProjectInfra", projectId]);
+ if (onSuccessCallback) onSuccessCallback(data,variables);
},
onError: (error) => {
- showToast(error.message || "Failed to update task details", "error");
+ showToast(error.message || "Failed to update Project Infra", "error");
},
});
};
@@ -432,4 +489,28 @@ export const useManageProjectAllocation = ({
isSuccess,
isError,
};
-};
\ No newline at end of file
+};
+
+export const useManageTask = ({onSuccessCallback}) =>
+{
+ const queryClient = useQueryClient();
+
+ return useMutation( {
+ mutationFn: async ( payload ) => await ProjectRepository.manageProjectTasks( payload ),
+ onSuccess: ( data, variables ) =>
+ {
+ queryClient.invalidateQueries(["WorkItems"])
+ showToast( 'Activity Updated Successfully', 'success' );
+ if (onSuccessCallback) onSuccessCallback(data);
+ },
+ onError: (error) =>
+ {
+ const message =
+ error?.response?.data?.message || error.message || 'Error occurred during API call';
+ showToast(message, 'error');
+
+ }
+
+ })
+}
+
diff --git a/src/pages/project/ProjectDetails.jsx b/src/pages/project/ProjectDetails.jsx
index 8eee41f5..e1067c06 100644
--- a/src/pages/project/ProjectDetails.jsx
+++ b/src/pages/project/ProjectDetails.jsx
@@ -78,14 +78,10 @@ const ProjectDetails = () => {
return (
- {/* About User */}
-
- {/* About User */}
+
- {/* Profile Overview */}
- {/* Profile Overview */}
);
@@ -95,7 +91,7 @@ const ProjectDetails = () => {
{/* Teams */}
-
+
{/* Teams */}
@@ -135,26 +131,12 @@ const ProjectDetails = () => {
useEffect(() => {
dispatch(setProjectId(projectId));
- // setProject(projects_Details);
- // setProjectDetails(projects_Details);
+
}, [projects_Details, projectId]);
const handler = useCallback(
(msg) => {
if (msg.keyword === "Update_Project" && project.id === msg.response.id) {
- // clearCacheKey("projectInfo")
- // ProjectRepository.getProjectByprojectId(projectId)
- // .then((response) => {
- // setProjectDetails(response.data);
- // setProject(response.data);
- // cacheData("projectInfo", { projectId, data: response.data });
- // setLoading(false);
- // })
- // .catch((error) => {
- // console.error(error);
- // setError("Failed to fetch data.");
- // setLoading(false);
- // });
refetch()
}
},
diff --git a/src/repositories/ProjectRepository.jsx b/src/repositories/ProjectRepository.jsx
index c63dfab4..55f5d195 100644
--- a/src/repositories/ProjectRepository.jsx
+++ b/src/repositories/ProjectRepository.jsx
@@ -23,7 +23,11 @@ const ProjectRepository = {
deleteProject: ( id ) => api.delete( `/projects/${ id }` ),
getProjectsByEmployee: ( id ) => api.get( `/api/project/assigned-projects/${ id }` ),
updateProjectsByEmployee:(id,data)=>api.post(`/api/project/assign-projects/${id}`,data),
- projectNameList:()=>api.get("/api/project/list/basic")
+ projectNameList: () => api.get( "/api/project/list/basic" ),
+
+ getProjectDetails:(id)=>api.get(`/api/project/details/${id}`),
+ getProjectInfraByproject: ( id ) => api.get( `/api/project/infra-details/${ id }` ),
+ getProjectTasksByWorkArea:(id)=>api.get(`/api/project/tasks/${id}`)
};
export const TasksRepository = {
diff --git a/src/utils/constants.jsx b/src/utils/constants.jsx
index ef0000de..fca560af 100644
--- a/src/utils/constants.jsx
+++ b/src/utils/constants.jsx
@@ -11,9 +11,9 @@ export const VIEW_PROJECTS = "6ea44136-987e-44ba-9e5d-1cf8f5837ebc"
export const MANAGE_EMPLOYEES = "a97d366a-c2bb-448d-be93-402bd2324566"
-export const MANAGE_PROJECT_INFRA = "f2aee20a-b754-4537-8166-f9507b44585b"
+export const MANAGE_PROJECT_INFRA = "cf2825ad-453b-46aa-91d9-27c124d63373"
-export const VIEW_PROJECT_INFRA = "c7b68e33-72f0-474f-bd96-77636427ecc8"
+export const VIEW_PROJECT_INFRA = "8d7cc6e3-9147-41f7-aaa7-fa507e450bd4"
export const REGULARIZE_ATTENDANCE ="57802c4a-00aa-4a1f-a048-fd2f70dd44b6"
|