Issues_July_3W : Fixed Infra Planning #265
@ -10,7 +10,7 @@ import ProjectRepository from "../../repositories/ProjectRepository";
|
|||||||
import Breadcrumb from "../../components/common/Breadcrumb";
|
import Breadcrumb from "../../components/common/Breadcrumb";
|
||||||
import {useProjectDetails, useProjectInfra, useProjects} from "../../hooks/useProjects";
|
import {useProjectDetails, useProjectInfra, useProjects} from "../../hooks/useProjects";
|
||||||
import {useHasUserPermission} from "../../hooks/useHasUserPermission";
|
import {useHasUserPermission} from "../../hooks/useHasUserPermission";
|
||||||
import {MANAGE_PROJECT_INFRA} from "../../utils/constants";
|
import {APPROVE_TASK, ASSIGN_REPORT_TASK, MANAGE_PROJECT_INFRA} from "../../utils/constants";
|
||||||
import {useDispatch, useSelector} from "react-redux";
|
import {useDispatch, useSelector} from "react-redux";
|
||||||
import {useProfile} from "../../hooks/useProfile";
|
import {useProfile} from "../../hooks/useProfile";
|
||||||
import {refreshData, setProjectId} from "../../slices/localVariablesSlice";
|
import {refreshData, setProjectId} from "../../slices/localVariablesSlice";
|
||||||
@ -27,6 +27,8 @@ const InfraPlanning = () =>
|
|||||||
|
|
||||||
|
|
||||||
const ManageInfra = useHasUserPermission( MANAGE_PROJECT_INFRA )
|
const ManageInfra = useHasUserPermission( MANAGE_PROJECT_INFRA )
|
||||||
|
const ApprovedTaskRights = useHasUserPermission(APPROVE_TASK)
|
||||||
|
const ReportTaskRights = useHasUserPermission(ASSIGN_REPORT_TASK)
|
||||||
const reloadedData = useSelector( ( store ) => store.localVariables.reload )
|
const reloadedData = useSelector( ( store ) => store.localVariables.reload )
|
||||||
|
|
||||||
|
|
||||||
@ -44,7 +46,7 @@ const InfraPlanning = () =>
|
|||||||
<div className="col-md-12 col-lg-12 col-xl-12 order-0 mb-4">
|
<div className="col-md-12 col-lg-12 col-xl-12 order-0 mb-4">
|
||||||
<div className="card">
|
<div className="card">
|
||||||
<div className="card-body" style={{ padding: "0.5rem" }}>
|
<div className="card-body" style={{ padding: "0.5rem" }}>
|
||||||
{ManageInfra ? (
|
{(ApprovedTaskRights || ReportTaskRights) ? (
|
||||||
<div className="align-items-center">
|
<div className="align-items-center">
|
||||||
<div className="row ">
|
<div className="row ">
|
||||||
{isLoading && ( <p>Loading...</p> )}
|
{isLoading && ( <p>Loading...</p> )}
|
||||||
@ -53,7 +55,7 @@ const InfraPlanning = () =>
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="text-center">
|
<div className="text-center my-2">
|
||||||
<i className="fa-solid fa-triangle-exclamation fs-5"></i>
|
<i className="fa-solid fa-triangle-exclamation fs-5"></i>
|
||||||
<p>Access Denied: You don't have permission to perform this action. !</p>
|
<p>Access Denied: You don't have permission to perform this action. !</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -29,7 +29,8 @@ const Header = () => {
|
|||||||
const HasManageProjectPermission = useHasUserPermission(MANAGE_PROJECT);
|
const HasManageProjectPermission = useHasUserPermission(MANAGE_PROJECT);
|
||||||
|
|
||||||
const isDirectoryPath = /^\/directory$/.test(location.pathname);
|
const isDirectoryPath = /^\/directory$/.test(location.pathname);
|
||||||
const isDashboard = /^\/dashboard$/.test(location.pathname);
|
const isProjectPath = /^\/projects$/.test(location.pathname);
|
||||||
|
const isDashboard = /^\/dashboard$/.test(location.pathname) || /^\/$/.test(location.pathname) ;
|
||||||
const getRole = (roles, joRoleId) => {
|
const getRole = (roles, joRoleId) => {
|
||||||
if (!Array.isArray(roles)) return "User";
|
if (!Array.isArray(roles)) return "User";
|
||||||
let role = roles.find((role) => role.id === joRoleId);
|
let role = roles.find((role) => role.id === joRoleId);
|
||||||
@ -159,6 +160,15 @@ const Header = () => {
|
|||||||
};
|
};
|
||||||
}, [handler, newProjectHandler]);
|
}, [handler, newProjectHandler]);
|
||||||
|
|
||||||
|
const handleProjectChange =(project)=>{
|
||||||
|
if(isProjectPath){
|
||||||
|
dispatch(setProjectId(project))
|
||||||
|
navigate("/projects/details")
|
||||||
|
} else{
|
||||||
|
dispatch(setProjectId(project))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<nav
|
<nav
|
||||||
className="layout-navbar container-fluid mb-3 navbar navbar-expand-xl navbar-detached align-items-center bg-navbar-theme"
|
className="layout-navbar container-fluid mb-3 navbar navbar-expand-xl navbar-detached align-items-center bg-navbar-theme"
|
||||||
@ -212,7 +222,7 @@ const Header = () => {
|
|||||||
<li key={project?.id}>
|
<li key={project?.id}>
|
||||||
<button
|
<button
|
||||||
className="dropdown-item"
|
className="dropdown-item"
|
||||||
onClick={() => dispatch(setProjectId(project?.id))}
|
onClick={()=>handleProjectChange(project?.id)}
|
||||||
>
|
>
|
||||||
{project?.name}
|
{project?.name}
|
||||||
{project?.shortName && (
|
{project?.shortName && (
|
||||||
|
|||||||
@ -238,8 +238,8 @@ const AssignTask = ({ assignData, onClose, setAssigned }) => {
|
|||||||
{selectedRole !== "" && (
|
{selectedRole !== "" && (
|
||||||
<div className="row">
|
<div className="row">
|
||||||
{employeeLoading ? (
|
{employeeLoading ? (
|
||||||
<div className="col-12 text-center py-3">
|
<div className="col-12">
|
||||||
<p className="mt-2">Loading employees...</p>
|
<p className="text-center">Loading employees...</p>
|
||||||
</div>
|
</div>
|
||||||
) : filteredEmployees?.length > 0 ? (
|
) : filteredEmployees?.length > 0 ? (
|
||||||
filteredEmployees.map((emp) => {
|
filteredEmployees.map((emp) => {
|
||||||
|
|||||||
@ -22,7 +22,7 @@ const WorkArea = ({ workArea, floor, forBuilding }) => {
|
|||||||
const [IsExpandedArea, setIsExpandedArea] = useState(false);
|
const [IsExpandedArea, setIsExpandedArea] = useState(false);
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const [Project, setProject] = useState();
|
const [Project, setProject] = useState();
|
||||||
const { projectId } = useParams();
|
// const { projectId } = useParams();
|
||||||
|
|
||||||
const ManageInfra = useHasUserPermission(MANAGE_PROJECT_INFRA);
|
const ManageInfra = useHasUserPermission(MANAGE_PROJECT_INFRA);
|
||||||
const ManageAndAssignTak = useHasUserPermission(ASSIGN_REPORT_TASK);
|
const ManageAndAssignTak = useHasUserPermission(ASSIGN_REPORT_TASK);
|
||||||
@ -125,7 +125,7 @@ const WorkArea = ({ workArea, floor, forBuilding }) => {
|
|||||||
{isLoading || ProjectTaskList === undefined ? (
|
{isLoading || ProjectTaskList === undefined ? (
|
||||||
<div className="text-center py-2 text-muted">Loading activities...</div>
|
<div className="text-center py-2 text-muted">Loading activities...</div>
|
||||||
) : ProjectTaskList?.length === 0 ? (
|
) : ProjectTaskList?.length === 0 ? (
|
||||||
<div className="text-center py-2 text-muted"> No activities available for this work area !</div>
|
<div className="text-center py-2 text-muted">No activities available for this work area.</div>
|
||||||
):ProjectTaskList?.length > 0 ? (
|
):ProjectTaskList?.length > 0 ? (
|
||||||
<table className="table table-sm mx-1">
|
<table className="table table-sm mx-1">
|
||||||
<thead>
|
<thead>
|
||||||
@ -144,7 +144,7 @@ const WorkArea = ({ workArea, floor, forBuilding }) => {
|
|||||||
Today's Planned
|
Today's Planned
|
||||||
</th>
|
</th>
|
||||||
<th className="infra-activity-table-header">Progress</th>
|
<th className="infra-activity-table-header">Progress</th>
|
||||||
{(ManageInfra || (!projectId && ManageAndAssignTak)) && (
|
{(ManageInfra || ManageAndAssignTak) && (
|
||||||
<th className="infra-activity-table-header text-end">
|
<th className="infra-activity-table-header text-end">
|
||||||
<span className="px-2">Actions</span>
|
<span className="px-2">Actions</span>
|
||||||
</th>
|
</th>
|
||||||
|
|||||||
@ -22,16 +22,20 @@ const ProjectList = () => {
|
|||||||
const { profile: loginUser } = useProfile();
|
const { profile: loginUser } = useProfile();
|
||||||
const [listView, setListView] = useState(false);
|
const [listView, setListView] = useState(false);
|
||||||
const [showModal, setShowModal] = useState(false);
|
const [showModal, setShowModal] = useState(false);
|
||||||
const selectedProject = useSelector((store)=>store.localVariables.projectId)
|
const selectedProject = useSelector(
|
||||||
const dispatch = useDispatch()
|
(store) => store.localVariables.projectId
|
||||||
|
);
|
||||||
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
const { projects, loading, error, refetch } = useProjects();
|
const { projects, loading, error, refetch } = useProjects();
|
||||||
const [projectList, setProjectList] = useState([]);
|
const [projectList, setProjectList] = useState([]);
|
||||||
|
|
||||||
const HasManageProjectPermission = useHasUserPermission(MANAGE_PROJECT);
|
const HasManageProjectPermission = useHasUserPermission(MANAGE_PROJECT);
|
||||||
const [HasManageProject, setHasManageProject] = useState(HasManageProjectPermission);
|
const [HasManageProject, setHasManageProject] = useState(
|
||||||
|
HasManageProjectPermission
|
||||||
|
);
|
||||||
|
|
||||||
const { mutate: createProject,isPending } = useCreateProject({
|
const { mutate: createProject, isPending } = useCreateProject({
|
||||||
onSuccessCallback: () => {
|
onSuccessCallback: () => {
|
||||||
setShowModal(false);
|
setShowModal(false);
|
||||||
},
|
},
|
||||||
@ -48,7 +52,9 @@ const ProjectList = () => {
|
|||||||
|
|
||||||
const handleShow = () => setShowModal(true);
|
const handleShow = () => setShowModal(true);
|
||||||
const handleClose = () => setShowModal(false);
|
const handleClose = () => setShowModal(false);
|
||||||
|
useEffect(() => {
|
||||||
|
dispatch(setProjectId(null));
|
||||||
|
}, []);
|
||||||
const sortingProject = (projects) => {
|
const sortingProject = (projects) => {
|
||||||
if (!loading && Array.isArray(projects)) {
|
if (!loading && Array.isArray(projects)) {
|
||||||
const grouped = {};
|
const grouped = {};
|
||||||
@ -74,14 +80,10 @@ const ProjectList = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if(selectedProject == null){
|
|
||||||
dispatch(setProjectId(projects[0]?.id));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!loading && projects) {
|
if (!loading && projects) {
|
||||||
sortingProject(projects);
|
sortingProject(projects);
|
||||||
}
|
}
|
||||||
}, [projects, loading, selectedStatuses]);
|
}, [projects, loading, selectedStatuses]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setHasManageProject(loginUser ? HasManageProjectPermission : false);
|
setHasManageProject(loginUser ? HasManageProjectPermission : false);
|
||||||
@ -114,12 +116,10 @@ const ProjectList = () => {
|
|||||||
|
|
||||||
const totalPages = Math.ceil(filteredProjects.length / ITEMS_PER_PAGE);
|
const totalPages = Math.ceil(filteredProjects.length / ITEMS_PER_PAGE);
|
||||||
|
|
||||||
const {
|
const { currentItems, currentPage, paginate, setCurrentPage } = usePagination(
|
||||||
currentItems,
|
filteredProjects,
|
||||||
currentPage,
|
ITEMS_PER_PAGE
|
||||||
paginate,
|
);
|
||||||
setCurrentPage,
|
|
||||||
} = usePagination(filteredProjects, ITEMS_PER_PAGE);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const tooltipTriggerList = Array.from(
|
const tooltipTriggerList = Array.from(
|
||||||
@ -130,17 +130,16 @@ const ProjectList = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
||||||
{showModal && (
|
{showModal && (
|
||||||
<GlobalModel isOpen={showModal} closeModal={handleClose}>
|
<GlobalModel isOpen={showModal} closeModal={handleClose}>
|
||||||
<ManageProjectInfo
|
<ManageProjectInfo
|
||||||
project={null}
|
project={null}
|
||||||
handleSubmitForm={handleSubmitForm}
|
handleSubmitForm={handleSubmitForm}
|
||||||
onClose={handleClose}
|
onClose={handleClose}
|
||||||
isPending={isPending}
|
isPending={isPending}
|
||||||
/>
|
/>
|
||||||
</GlobalModel>
|
</GlobalModel>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="container-fluid">
|
<div className="container-fluid">
|
||||||
<Breadcrumb
|
<Breadcrumb
|
||||||
@ -211,7 +210,7 @@ const ProjectList = () => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "cdad86aa-8a56-4ff4-b633-9c629057dfef",
|
id: "cdad86aa-8a56-4ff4-b633-9c629057dfef",
|
||||||
label:"In Progress"
|
label: "In Progress",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "603e994b-a27f-4e5d-a251-f3d69b0498ba",
|
id: "603e994b-a27f-4e5d-a251-f3d69b0498ba",
|
||||||
@ -269,11 +268,14 @@ const ProjectList = () => {
|
|||||||
{listView ? (
|
{listView ? (
|
||||||
<div className="card cursor-pointer">
|
<div className="card cursor-pointer">
|
||||||
<div className="card-body p-2">
|
<div className="card-body p-2">
|
||||||
<div className="table-responsive text-nowrap py-2 " style={{minHeight:"400px"}}>
|
<div
|
||||||
|
className="table-responsive text-nowrap py-2 "
|
||||||
|
style={{ minHeight: "400px" }}
|
||||||
|
>
|
||||||
<table className="table m-3">
|
<table className="table m-3">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th className="text-start" colSpan={5} >
|
<th className="text-start" colSpan={5}>
|
||||||
Project Name
|
Project Name
|
||||||
</th>
|
</th>
|
||||||
<th className="mx-2 text-start">Contact Person</th>
|
<th className="mx-2 text-start">Contact Person</th>
|
||||||
@ -298,8 +300,8 @@ const ProjectList = () => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "cdad86aa-8a56-4ff4-b633-9c629057dfef",
|
id: "cdad86aa-8a56-4ff4-b633-9c629057dfef",
|
||||||
label:"In Progress"
|
label: "In Progress",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "603e994b-a27f-4e5d-a251-f3d69b0498ba",
|
id: "603e994b-a27f-4e5d-a251-f3d69b0498ba",
|
||||||
label: "On Hold",
|
label: "On Hold",
|
||||||
@ -342,7 +344,11 @@ const ProjectList = () => {
|
|||||||
<tbody className="table-border-bottom-0 overflow-auto ">
|
<tbody className="table-border-bottom-0 overflow-auto ">
|
||||||
{currentItems.length === 0 ? (
|
{currentItems.length === 0 ? (
|
||||||
<tr className="text-center">
|
<tr className="text-center">
|
||||||
<td colSpan="12" rowSpan='12'style={{height:"200px"}} >
|
<td
|
||||||
|
colSpan="12"
|
||||||
|
rowSpan="12"
|
||||||
|
style={{ height: "200px" }}
|
||||||
|
>
|
||||||
No projects found
|
No projects found
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user