Compare commits

..

No commits in common. "43e173d0efefff65aa4a084b3a83d61765041614" and "07373f618064007afff165b2c7774cabf3148309" have entirely different histories.

5 changed files with 58 additions and 78 deletions

View File

@ -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 {APPROVE_TASK, ASSIGN_REPORT_TASK, MANAGE_PROJECT_INFRA} from "../../utils/constants"; import {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,8 +27,6 @@ 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 )
@ -46,7 +44,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" }}>
{(ApprovedTaskRights || ReportTaskRights) ? ( {ManageInfra ? (
<div className="align-items-center"> <div className="align-items-center">
<div className="row "> <div className="row ">
{isLoading && ( <p>Loading...</p> )} {isLoading && ( <p>Loading...</p> )}

View File

@ -29,7 +29,6 @@ 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 isProjectPath = /^\/projects$/.test(location.pathname);
const isDashboard = /^\/dashboard$/.test(location.pathname) || /^\/$/.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";
@ -160,15 +159,6 @@ 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"
@ -222,7 +212,7 @@ const Header = () => {
<li key={project?.id}> <li key={project?.id}>
<button <button
className="dropdown-item" className="dropdown-item"
onClick={()=>handleProjectChange(project?.id)} onClick={() => dispatch(setProjectId(project?.id))}
> >
{project?.name} {project?.name}
{project?.shortName && ( {project?.shortName && (

View File

@ -15,7 +15,8 @@ import { useCreateTask } from "../../hooks/useTasks";
const AssignTask = ({ assignData, onClose, setAssigned }) => { const AssignTask = ({ assignData, onClose, setAssigned }) => {
const maxPlanned = const maxPlanned =
assignData?.workItem?.plannedWork - assignData?.workItem?.completedWork; assignData?.workItem?.plannedWork -
assignData?.workItem?.completedWork;
const schema = z.object({ const schema = z.object({
selectedEmployees: z selectedEmployees: z
.array(z.string()) .array(z.string())
@ -78,7 +79,7 @@ const AssignTask = ({ assignData, onClose, setAssigned }) => {
employees, employees,
loading: employeeLoading, loading: employeeLoading,
recallEmployeeData, recallEmployeeData,
} = useEmployeesAllOrByProjectId(false, selectedProject, false); } = useEmployeesAllOrByProjectId(selectedProject, false);
const dispatch = useDispatch(); const dispatch = useDispatch();
const { loading } = useMaster(); const { loading } = useMaster();
const {data:jobRoleData} = useMaster(); const {data:jobRoleData} = useMaster();
@ -136,12 +137,11 @@ const AssignTask = ({ assignData, onClose, setAssigned }) => {
(emp) => String(emp.jobRoleId || "") === selectedRole (emp) => String(emp.jobRoleId || "") === selectedRole
); );
const onSubmit = (data) => { const onSubmit = (data) => {
const selectedEmployeeIds = data.selectedEmployees; const selectedEmployeeIds = data.selectedEmployees;
const taskTeamWithDetails = selectedEmployeeIds const taskTeamWithDetails = selectedEmployeeIds?.map((empId) => empId)?.filter(Boolean);
?.map((empId) => empId)
?.filter(Boolean);
const formattedData = { const formattedData = {
taskTeam: taskTeamWithDetails, taskTeam: taskTeamWithDetails,
plannedTask: data.plannedTask, plannedTask: data.plannedTask,
@ -149,10 +149,7 @@ const AssignTask = ({ assignData, onClose, setAssigned }) => {
assignmentDate: new Date().toISOString(), assignmentDate: new Date().toISOString(),
workItemId: assignData?.workItem.id, workItemId: assignData?.workItem.id,
}; };
assignTask({ assignTask({payload:formattedData,workAreaId:assignData?.workArea?.id});
payload: formattedData,
workAreaId: assignData?.workArea?.id,
});
}; };
const closedModel = () => { const closedModel = () => {
@ -237,12 +234,12 @@ const AssignTask = ({ assignData, onClose, setAssigned }) => {
<div className="col-12 h-sm-25 overflow-auto mt-2"> <div className="col-12 h-sm-25 overflow-auto mt-2">
{selectedRole !== "" && ( {selectedRole !== "" && (
<div className="row"> <div className="row">
{employeeLoading ? ( {loading ? ( // Assuming 'loading' here refers to master data loading
<div className="col-12"> <div className="col-12">
<p className="text-center">Loading employees...</p> <p className="text-center">Loading roles...</p>
</div> </div>
) : filteredEmployees?.length > 0 ? ( ) : filteredEmployees?.length > 0 ? (
filteredEmployees.map((emp) => { filteredEmployees?.map((emp) => {
const jobRole = jobRoleData?.find( const jobRole = jobRoleData?.find(
(role) => role?.id === emp?.jobRoleId (role) => role?.id === emp?.jobRoleId
); );
@ -351,6 +348,7 @@ const AssignTask = ({ assignData, onClose, setAssigned }) => {
{!loading && errors.selectedEmployees && ( {!loading && errors.selectedEmployees && (
<div className="danger-text mt-1"> <div className="danger-text mt-1">
<p>{errors.selectedEmployees.message}</p>{" "} <p>{errors.selectedEmployees.message}</p>{" "}
</div> </div>
)} )}

View File

@ -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">Loading activities...</div>
):ProjectTaskList?.length > 0 ? ( ):ProjectTaskList?.length > 0 ? (
<table className="table table-sm mx-1"> <table className="table table-sm mx-1">
<thead> <thead>

View File

@ -22,18 +22,14 @@ 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( const selectedProject = useSelector((store)=>store.localVariables.projectId)
(store) => store.localVariables.projectId const dispatch = useDispatch()
);
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( const [HasManageProject, setHasManageProject] = useState(HasManageProjectPermission);
HasManageProjectPermission
);
const { mutate: createProject,isPending } = useCreateProject({ const { mutate: createProject,isPending } = useCreateProject({
onSuccessCallback: () => { onSuccessCallback: () => {
@ -52,9 +48,7 @@ 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 = {};
@ -80,6 +74,10 @@ const ProjectList = () => {
}; };
useEffect(() => { useEffect(() => {
if(selectedProject == null){
dispatch(setProjectId(projects[0]?.id));
}
if (!loading && projects) { if (!loading && projects) {
sortingProject(projects); sortingProject(projects);
} }
@ -116,10 +114,12 @@ const ProjectList = () => {
const totalPages = Math.ceil(filteredProjects.length / ITEMS_PER_PAGE); const totalPages = Math.ceil(filteredProjects.length / ITEMS_PER_PAGE);
const { currentItems, currentPage, paginate, setCurrentPage } = usePagination( const {
filteredProjects, currentItems,
ITEMS_PER_PAGE currentPage,
); paginate,
setCurrentPage,
} = usePagination(filteredProjects, ITEMS_PER_PAGE);
useEffect(() => { useEffect(() => {
const tooltipTriggerList = Array.from( const tooltipTriggerList = Array.from(
@ -130,6 +130,7 @@ const ProjectList = () => {
return ( return (
<> <>
{showModal && ( {showModal && (
<GlobalModel isOpen={showModal} closeModal={handleClose}> <GlobalModel isOpen={showModal} closeModal={handleClose}>
<ManageProjectInfo <ManageProjectInfo
@ -210,7 +211,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",
@ -268,10 +269,7 @@ 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 <div className="table-responsive text-nowrap py-2 " style={{minHeight:"400px"}}>
className="table-responsive text-nowrap py-2 "
style={{ minHeight: "400px" }}
>
<table className="table m-3"> <table className="table m-3">
<thead> <thead>
<tr> <tr>
@ -300,7 +298,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",
@ -344,11 +342,7 @@ 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 <td colSpan="12" rowSpan='12'style={{height:"200px"}} >
colSpan="12"
rowSpan="12"
style={{ height: "200px" }}
>
No projects found No projects found
</td> </td>
</tr> </tr>