Compare commits
No commits in common. "2d7c7ada965355dd7f9dfcbef08ee6bff70b3909" and "11dc196ae8b6d81144be5af23024ce6e2798262c" have entirely different histories.
2d7c7ada96
...
11dc196ae8
4
public/assets/vendor/css/core.css
vendored
4
public/assets/vendor/css/core.css
vendored
@ -836,7 +836,7 @@ progress {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.row {
|
.row {
|
||||||
--bs-gutter-x: 0.500rem;
|
--bs-gutter-x: 3.625rem;
|
||||||
--bs-gutter-y: 0;
|
--bs-gutter-y: 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
@ -2553,7 +2553,7 @@ progress {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.table-responsive {
|
.table-responsive {
|
||||||
overflow-x: auto;
|
/* overflow-x: auto; */
|
||||||
-webkit-overflow-scrolling: touch;
|
-webkit-overflow-scrolling: touch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -62,12 +62,7 @@ export const ReportTask = ({ report, closeModal }) => {
|
|||||||
checkList: [],
|
checkList: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
reportTask({
|
reportTask({ reportData, workAreaId: report?.workItem?.workArea?.id });
|
||||||
reportData,
|
|
||||||
workAreaId: report?.workItem?.workArea?.id,
|
|
||||||
buildingId: report?.workItem?.workArea?.floor?.building.id,
|
|
||||||
floorId: report?.workItem?.workArea?.floor?.id,
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
closeModal();
|
closeModal();
|
||||||
|
|||||||
@ -38,12 +38,13 @@ const SubTask = ({ activity, onClose }) => {
|
|||||||
const selectedActivityId = watch("activityId");
|
const selectedActivityId = watch("activityId");
|
||||||
const selectedActivity = activities?.find((a) => a.id === selectedActivityId);
|
const selectedActivity = activities?.find((a) => a.id === selectedActivityId);
|
||||||
const {mutate:createSubTask,isPending } = useManageTask( {
|
const {mutate:createSubTask,isPending } = useManageTask( {
|
||||||
onSuccessCallback: () => {
|
onSuccessCallback: () =>
|
||||||
showToast("Sub Task Created Successfully", "success");
|
{
|
||||||
|
showToast("Sub Task Created Successfully","success")
|
||||||
reset();
|
reset();
|
||||||
onClose();
|
onClose();
|
||||||
},
|
}
|
||||||
});
|
} )
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setCategoryData(categories);
|
setCategoryData(categories);
|
||||||
@ -72,7 +73,7 @@ const SubTask = ({ activity, onClose }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onSubmitForm = async (formData) => {
|
const onSubmitForm = async (formData) => {
|
||||||
let data = {
|
let payload = {
|
||||||
workAreaID: Task.workItem.workAreaId,
|
workAreaID: Task.workItem.workAreaId,
|
||||||
workCategoryId: formData.workCategoryId,
|
workCategoryId: formData.workCategoryId,
|
||||||
activityID: formData.activityId,
|
activityID: formData.activityId,
|
||||||
@ -82,18 +83,7 @@ const SubTask = ({ activity, onClose }) => {
|
|||||||
comment: formData.comment,
|
comment: formData.comment,
|
||||||
};
|
};
|
||||||
|
|
||||||
const payload = [data];
|
createSubTask([payload])
|
||||||
let buildingId = activity.workItem.workArea.floor.building.id;
|
|
||||||
let floorId = activity.workItem.workArea.floor.id;
|
|
||||||
let workAreaId = activity.workItem.workArea.id;
|
|
||||||
createSubTask({
|
|
||||||
payload: payload,
|
|
||||||
buildingId: buildingId,
|
|
||||||
floorId: floorId,
|
|
||||||
workAreaId: workAreaId,
|
|
||||||
PreviousPlannedWork:0,
|
|
||||||
previousCompletedWork:0
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<div className="container-xxl my-1">
|
<div className="container-xxl my-1">
|
||||||
|
|||||||
@ -116,17 +116,7 @@ useEffect(() => {
|
|||||||
floorId: floor?.id,
|
floorId: floor?.id,
|
||||||
workAreaId: workArea?.id,
|
workAreaId: workArea?.id,
|
||||||
};
|
};
|
||||||
let plannedTask =
|
UpdateTask([payload])
|
||||||
workItem?.workItem?.plannedWork || workItem?.plannedWork || 0;
|
|
||||||
let completedTask = workItem?.workItem?.completedWork || workItem?.completedWork || 0
|
|
||||||
UpdateTask({
|
|
||||||
payload: [payload],
|
|
||||||
PreviousPlannedWork: plannedTask,
|
|
||||||
buildingId: building?.id,
|
|
||||||
floorId: floor?.id,
|
|
||||||
workAreaId: workArea?.id,
|
|
||||||
previousCompletedWork:completedTask
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<form className="row g-2 p-2 p-md-1" onSubmit={handleSubmit(onSubmitForm)}>
|
<form className="row g-2 p-2 p-md-1" onSubmit={handleSubmit(onSubmitForm)}>
|
||||||
|
|||||||
@ -69,9 +69,10 @@ const TaskModel = ({ project, onSubmit, onClose }) => {
|
|||||||
const selectedCategory = categoryData?.find((c) => c.id === watchCategoryId);
|
const selectedCategory = categoryData?.find((c) => c.id === watchCategoryId);
|
||||||
|
|
||||||
const { mutate: CreateTask, isPending } = useManageTask({
|
const { mutate: CreateTask, isPending } = useManageTask({
|
||||||
onSuccessCallback: (response) => {
|
onSuccessCallback: ( response ) =>
|
||||||
showToast(response?.message, "success");
|
{
|
||||||
onClose?.();
|
showToast( response?.message, "success" )
|
||||||
|
onClose?.()
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -96,9 +97,7 @@ const TaskModel = ({ project, onSubmit, onClose }) => {
|
|||||||
|
|
||||||
const onSubmitForm = async (data) => {
|
const onSubmitForm = async (data) => {
|
||||||
const payload = [data];
|
const payload = [data];
|
||||||
CreateTask({payload:payload,buildingId: data.buildingID,
|
CreateTask(payload);
|
||||||
floorId: data.floorId,
|
|
||||||
workAreaId: data.workAreaId, PreviousPlannedWork:0,previousCompletedWork:0});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -10,10 +10,7 @@ import {
|
|||||||
} from "../../../utils/constants";
|
} from "../../../utils/constants";
|
||||||
import ConfirmModal from "../../common/ConfirmModal";
|
import ConfirmModal from "../../common/ConfirmModal";
|
||||||
import ProjectRepository from "../../../repositories/ProjectRepository";
|
import ProjectRepository from "../../../repositories/ProjectRepository";
|
||||||
import {
|
import { useDeleteProjectTask, useProjectDetails } from "../../../hooks/useProjects";
|
||||||
useDeleteProjectTask,
|
|
||||||
useProjectDetails,
|
|
||||||
} from "../../../hooks/useProjects";
|
|
||||||
import showToast from "../../../services/toastService";
|
import showToast from "../../../services/toastService";
|
||||||
import {
|
import {
|
||||||
cacheData,
|
cacheData,
|
||||||
@ -43,6 +40,7 @@ const WorkItem = ({
|
|||||||
const [loadingDelete, setLoadingDelete] = useState(false);
|
const [loadingDelete, setLoadingDelete] = useState(false);
|
||||||
const project = getCachedData("projectInfo");
|
const project = getCachedData("projectInfo");
|
||||||
|
|
||||||
|
|
||||||
const openModal = () => setIsModalOpen(true);
|
const openModal = () => setIsModalOpen(true);
|
||||||
const closeModal = () => setIsModalOpen( false );
|
const closeModal = () => setIsModalOpen( false );
|
||||||
|
|
||||||
@ -71,7 +69,7 @@ const WorkItem = ({
|
|||||||
};
|
};
|
||||||
setNewWorkItem(updated);
|
setNewWorkItem(updated);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
let assigndata = {
|
let assigndata = {
|
||||||
building: forBuilding,
|
building: forBuilding,
|
||||||
floor: forFloor,
|
floor: forFloor,
|
||||||
@ -87,17 +85,15 @@ const WorkItem = ({
|
|||||||
tooltipTriggerList.forEach((el) => new bootstrap.Tooltip(el));
|
tooltipTriggerList.forEach((el) => new bootstrap.Tooltip(el));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
let WorkItemId = workItem.workItemId || workItem.id;
|
let WorkItemId = workItem.workItemId || workItem.id;
|
||||||
debugger
|
DeleteTask({workItemId:WorkItemId,workAreaId:forWorkArea?.id})
|
||||||
DeleteTask({
|
|
||||||
workItemId: WorkItemId,
|
|
||||||
workAreaId: forWorkArea?.id,
|
|
||||||
completedTask: workItem?.completedWork,
|
|
||||||
plannedTask: workItem?.plannedWork,
|
|
||||||
buildingId: forBuilding?.id,
|
|
||||||
floorId: forFloor?.id,
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const PlannedWork =
|
const PlannedWork =
|
||||||
@ -108,20 +104,12 @@ const WorkItem = ({
|
|||||||
<>
|
<>
|
||||||
{isModalOpen && (
|
{isModalOpen && (
|
||||||
<GlobalModel isOpen={isModalOpen} size="lg" closeModal={closeModal}>
|
<GlobalModel isOpen={isModalOpen} size="lg" closeModal={closeModal}>
|
||||||
<AssignTask
|
<AssignTask assignData={assigndata} onClose={closeModal} setAssigned={refreshWorkItem} />
|
||||||
assignData={assigndata}
|
|
||||||
onClose={closeModal}
|
|
||||||
setAssigned={refreshWorkItem}
|
|
||||||
/>
|
|
||||||
</GlobalModel>
|
</GlobalModel>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{showModal && (
|
{showModal && (
|
||||||
<GlobalModel
|
<GlobalModel isOpen={showModal} size="lg" closeModal={()=>setShowModal(false)}>
|
||||||
isOpen={showModal}
|
|
||||||
size="lg"
|
|
||||||
closeModal={() => setShowModal(false)}
|
|
||||||
>
|
|
||||||
<EditActivityModal
|
<EditActivityModal
|
||||||
workItem={workItem}
|
workItem={workItem}
|
||||||
workArea={forWorkArea}
|
workArea={forWorkArea}
|
||||||
@ -179,6 +167,7 @@ const WorkItem = ({
|
|||||||
: "NA"}
|
: "NA"}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
|
||||||
<td className="text-center table-cell-small d-none d-md-table-cell">
|
<td className="text-center table-cell-small d-none d-md-table-cell">
|
||||||
<span className="fw-light">
|
<span className="fw-light">
|
||||||
{hasWorkItem
|
{hasWorkItem
|
||||||
@ -206,7 +195,9 @@ const WorkItem = ({
|
|||||||
<td className="text-center d-none d-md-table-cell">
|
<td className="text-center d-none d-md-table-cell">
|
||||||
{hasWorkItem
|
{hasWorkItem
|
||||||
? `${
|
? `${
|
||||||
NewWorkItem?.todaysAssigned ?? workItem?.todaysAssigned ?? "0"
|
NewWorkItem?.todaysAssigned ??
|
||||||
|
workItem?.todaysAssigned ??
|
||||||
|
"0"
|
||||||
}`
|
}`
|
||||||
: "NA"}
|
: "NA"}
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { formatNumber, getCompletionPercentage, getDateDifferenceInDays } from "../../utils/dateUtils";
|
import { formatNumber, getDateDifferenceInDays } from "../../utils/dateUtils";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useProjectDetails, useUpdateProject } from "../../hooks/useProjects";
|
import { useProjectDetails, useUpdateProject } from "../../hooks/useProjects";
|
||||||
import ManageProjectInfo from "./ManageProjectInfo";
|
import ManageProjectInfo from "./ManageProjectInfo";
|
||||||
@ -227,7 +227,12 @@ const ProjectCard = ({ projectData, recall }) => {
|
|||||||
Task: {formatNumber(projectInfo.completedWork)} / {formatNumber(projectInfo.plannedWork)}
|
Task: {formatNumber(projectInfo.completedWork)} / {formatNumber(projectInfo.plannedWork)}
|
||||||
</small>
|
</small>
|
||||||
<small className="text-body">
|
<small className="text-body">
|
||||||
{getCompletionPercentage(projectInfo.completedWork, projectInfo.plannedWork)}
|
{Math.floor(
|
||||||
|
getProgressInNumber(
|
||||||
|
projectInfo.plannedWork,
|
||||||
|
projectInfo.completedWork
|
||||||
|
)
|
||||||
|
) || 0}{" "}
|
||||||
% Completed
|
% Completed
|
||||||
</small>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import {
|
|||||||
useEmployeesByProjectAllocated,
|
useEmployeesByProjectAllocated,
|
||||||
useProjects,
|
useProjects,
|
||||||
} from "../../hooks/useProjects";
|
} from "../../hooks/useProjects";
|
||||||
import { formatNumber, getCompletionPercentage } from "../../utils/dateUtils";
|
import { formatNumber } from "../../utils/dateUtils";
|
||||||
import ProgressBar from "../common/ProgressBar";
|
import ProgressBar from "../common/ProgressBar";
|
||||||
|
|
||||||
const ProjectOverview = ({ project }) => {
|
const ProjectOverview = ({ project }) => {
|
||||||
@ -49,8 +49,9 @@ const ProjectOverview = ({ project }) => {
|
|||||||
)
|
)
|
||||||
) || 0}{" "} */}
|
) || 0}{" "} */}
|
||||||
{
|
{
|
||||||
getCompletionPercentage( formatNumber(project_detail.completedWork),formatNumber(project_detail.plannedWork))
|
(formatNumber(project_detail.plannedWork),
|
||||||
|
"/",
|
||||||
|
formatNumber(project_detail.completedWork))
|
||||||
}
|
}
|
||||||
% Completed
|
% Completed
|
||||||
</small>
|
</small>
|
||||||
|
|||||||
@ -6,12 +6,7 @@ import { useDispatch, useSelector } from "react-redux";
|
|||||||
import { setProjectId } from "../slices/localVariablesSlice";
|
import { setProjectId } from "../slices/localVariablesSlice";
|
||||||
import EmployeeList from "../components/Directory/EmployeeList";
|
import EmployeeList from "../components/Directory/EmployeeList";
|
||||||
import eventBus from "../services/eventBus";
|
import eventBus from "../services/eventBus";
|
||||||
import {
|
import {Mutation, useMutation, useQuery, useQueryClient} from "@tanstack/react-query";
|
||||||
Mutation,
|
|
||||||
useMutation,
|
|
||||||
useQuery,
|
|
||||||
useQueryClient,
|
|
||||||
} from "@tanstack/react-query";
|
|
||||||
import showToast from "../services/toastService";
|
import showToast from "../services/toastService";
|
||||||
|
|
||||||
// export const useProjects = () => {
|
// export const useProjects = () => {
|
||||||
@ -216,7 +211,7 @@ export const useProjects = () => {
|
|||||||
error,
|
error,
|
||||||
refetch,
|
refetch,
|
||||||
} = useQuery({
|
} = useQuery({
|
||||||
queryKey: ["ProjectsList"],
|
queryKey: ['ProjectsList'],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const response = await ProjectRepository.getProjectList();
|
const response = await ProjectRepository.getProjectList();
|
||||||
return response.data;
|
return response.data;
|
||||||
@ -232,99 +227,84 @@ export const useProjects = () => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useEmployeesByProjectAllocated = (selectedProject) => {
|
export const useEmployeesByProjectAllocated = (selectedProject) =>
|
||||||
const {
|
{
|
||||||
data = [],
|
const {data = [], isLoading, refetch, error} = useQuery( {
|
||||||
isLoading,
|
|
||||||
refetch,
|
|
||||||
error,
|
|
||||||
} = useQuery({
|
|
||||||
queryKey: ["empListByProjectAllocated", selectedProject ],
|
queryKey: ["empListByProjectAllocated", selectedProject ],
|
||||||
queryFn: async () => {
|
queryFn: async () =>
|
||||||
|
{
|
||||||
const res = await ProjectRepository.getProjectAllocation( selectedProject );
|
const res = await ProjectRepository.getProjectAllocation( selectedProject );
|
||||||
return res.data || res;
|
return res.data || res
|
||||||
},
|
},
|
||||||
enabled: !!selectedProject,
|
enabled: !!selectedProject,
|
||||||
onError: (error) => {
|
onError: ( error ) =>
|
||||||
showToast(
|
{
|
||||||
error.message || "Error while Fetching project Allocated Employees",
|
showToast(error.message || "Error while Fetching project Allocated Employees", "error");
|
||||||
"error"
|
}
|
||||||
);
|
} )
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
projectEmployees: data,
|
projectEmployees: data,
|
||||||
loading:isLoading,
|
loading:isLoading,
|
||||||
error,
|
error,
|
||||||
refetch,
|
refetch
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
export const useProjectDetails = (projectId, isAuto = true) => {
|
export const useProjectDetails = ( projectId,isAuto = true ) =>
|
||||||
const {
|
{
|
||||||
data: projects_Details,
|
const {data: projects_Details, isLoading, error, refetch} = useQuery( {
|
||||||
isLoading,
|
|
||||||
error,
|
|
||||||
refetch,
|
|
||||||
} = useQuery({
|
|
||||||
queryKey: [ "projectInfo", projectId ],
|
queryKey: [ "projectInfo", projectId ],
|
||||||
queryFn: async () => {
|
queryFn: async () =>
|
||||||
|
{
|
||||||
const res = await ProjectRepository.getProjectByprojectId( projectId );
|
const res = await ProjectRepository.getProjectByprojectId( projectId );
|
||||||
return res.data || res;
|
return res.data || res;
|
||||||
},
|
},
|
||||||
enabled: !!projectId && isAuto,
|
enabled: !!projectId && isAuto,
|
||||||
onError: (error) => {
|
onError: ( error ) =>
|
||||||
showToast(
|
{
|
||||||
error.message || "Error while Fetching project Details",
|
showToast(error.message || "Error while Fetching project Details", "error");
|
||||||
"error"
|
}
|
||||||
);
|
} )
|
||||||
},
|
|
||||||
});
|
|
||||||
return { projects_Details, loading:isLoading, error, refetch };
|
return { projects_Details, loading:isLoading, error, refetch };
|
||||||
};
|
}
|
||||||
|
|
||||||
export const useProjectsByEmployee = (employeeId) => {
|
export const useProjectsByEmployee = (employeeId) =>
|
||||||
const {
|
{
|
||||||
data: projectNameList = [],
|
const { data:projectNameList =[],isLoading,error,refetch} = useQuery( {
|
||||||
isLoading,
|
|
||||||
error,
|
|
||||||
refetch,
|
|
||||||
} = useQuery({
|
|
||||||
queryKey: [ "ProjectsByEmployee", employeeId ],
|
queryKey: [ "ProjectsByEmployee", employeeId ],
|
||||||
queryFn: async () => {
|
queryFn: async () =>
|
||||||
|
{
|
||||||
const res = await ProjectRepository.getProjectsByEmployee( employeeId );
|
const res = await ProjectRepository.getProjectsByEmployee( employeeId );
|
||||||
return res.data || res;
|
return res.data || res;
|
||||||
},
|
},
|
||||||
enabled: !!employeeId,
|
enabled: !!employeeId,
|
||||||
onError: (error) => {
|
onError: ( error ) =>
|
||||||
showToast(
|
{
|
||||||
error.message || "Error while Fetching project Employee",
|
showToast(error.message || "Error while Fetching project Employee", "error");
|
||||||
"error"
|
}
|
||||||
);
|
})
|
||||||
},
|
return {projectList, loading:isLoading,error,refetch }
|
||||||
});
|
}
|
||||||
return { projectList, loading: isLoading, error, refetch };
|
|
||||||
};
|
|
||||||
|
|
||||||
export const useProjectName = () => {
|
export const useProjectName = () =>
|
||||||
const {
|
{
|
||||||
data = [],
|
const {data = [],isLoading,error,refetch} = useQuery( {
|
||||||
isLoading,
|
|
||||||
error,
|
|
||||||
refetch,
|
|
||||||
} = useQuery({
|
|
||||||
queryKey: [ "basicProjectNameList" ],
|
queryKey: [ "basicProjectNameList" ],
|
||||||
queryFn: async () => {
|
queryFn: async () =>
|
||||||
|
{
|
||||||
const res = await ProjectRepository.projectNameList();
|
const res = await ProjectRepository.projectNameList();
|
||||||
return res.data || res;
|
return res.data || res;
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: ( error ) =>
|
||||||
|
{
|
||||||
showToast(error.message || "Error while Fetching project Name", "error");
|
showToast(error.message || "Error while Fetching project Name", "error");
|
||||||
},
|
}
|
||||||
});
|
} )
|
||||||
return { projectNames: data, loading: isLoading, Error: error, refetch };
|
return {projectNames:data,loading:isLoading,Error:error,refetch}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export const useProjectInfra = (projectId) => {
|
export const useProjectInfra = (projectId) => {
|
||||||
const {
|
const {
|
||||||
@ -346,27 +326,30 @@ export const useProjectInfra = (projectId) => {
|
|||||||
return { projectInfra, isLoading, error };
|
return { projectInfra, isLoading, error };
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useProjectTasks = (workAreaId, IsExpandedArea = false) => {
|
|
||||||
const {
|
export const useProjectTasks = (workAreaId,IsExpandedArea=false) =>
|
||||||
data: ProjectTaskList,
|
{
|
||||||
isLoading,
|
const { data:ProjectTaskList,isLoading,error } = useQuery( {
|
||||||
error,
|
|
||||||
} = useQuery({
|
|
||||||
queryKey: [ "WorkItems",workAreaId ],
|
queryKey: [ "WorkItems",workAreaId ],
|
||||||
queryFn: async () => {
|
queryFn: async () =>
|
||||||
|
{
|
||||||
const res = await ProjectRepository.getProjectTasksByWorkArea(workAreaId);
|
const res = await ProjectRepository.getProjectTasksByWorkArea(workAreaId);
|
||||||
return res.data;
|
return res.data;
|
||||||
},
|
},
|
||||||
enabled: !!workAreaId && !!IsExpandedArea,
|
enabled: !!workAreaId && !!IsExpandedArea,
|
||||||
onError: (error) => {
|
onError: ( error ) =>
|
||||||
|
{
|
||||||
showToast(error.message || "Error while Fetching project Tasks", "error");
|
showToast(error.message || "Error while Fetching project Tasks", "error");
|
||||||
},
|
}
|
||||||
});
|
} )
|
||||||
return { ProjectTaskList, isLoading, error };
|
return {ProjectTaskList,isLoading,error}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
// -- -------------Mutation-------------------------------
|
// -- -------------Mutation-------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export const useCreateProject = ({ onSuccessCallback }) => {
|
export const useCreateProject = ({ onSuccessCallback }) => {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
@ -377,8 +360,8 @@ export const useCreateProject = ({ onSuccessCallback }) => {
|
|||||||
},
|
},
|
||||||
onSuccess: (data) => {
|
onSuccess: (data) => {
|
||||||
// Invalidate the cache
|
// Invalidate the cache
|
||||||
queryClient.invalidateQueries({ queryKey: ["ProjectsList"] });
|
queryClient.invalidateQueries( {queryKey: [ 'ProjectsList' ]} );
|
||||||
queryClient.invalidateQueries({ queryKey: ["basicProjectNameList"] });
|
queryClient.invalidateQueries({queryKey:['basicProjectNameList']});
|
||||||
|
|
||||||
// Emit event for consumers (like useProjects or others)
|
// Emit event for consumers (like useProjects or others)
|
||||||
eventBus.emit("project", {
|
eventBus.emit("project", {
|
||||||
@ -398,19 +381,27 @@ export const useCreateProject = ({ onSuccessCallback }) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export const useUpdateProject = ({ onSuccessCallback }) => {
|
export const useUpdateProject = ({ onSuccessCallback }) => {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const { mutate, isPending, isSuccess, isError } = useMutation({
|
const {
|
||||||
mutationFn: async ({ projectId, updatedData }) => {
|
mutate,
|
||||||
|
isPending,
|
||||||
|
isSuccess,
|
||||||
|
isError,
|
||||||
|
} = useMutation({
|
||||||
|
mutationFn: async ( {projectId, updatedData} ) =>
|
||||||
|
{
|
||||||
return await ProjectRepository.updateProject(projectId, updatedData);
|
return await ProjectRepository.updateProject(projectId, updatedData);
|
||||||
},
|
},
|
||||||
|
|
||||||
onSuccess: (data, variables) => {
|
onSuccess: ( data, variables ) =>
|
||||||
|
{
|
||||||
const { projectId } = variables;
|
const { projectId } = variables;
|
||||||
|
|
||||||
queryClient.invalidateQueries({queryKey:["ProjectsList"]});
|
queryClient.invalidateQueries({queryKey:["ProjectsList"]});
|
||||||
queryClient.invalidateQueries( {queryKey: [ "projectInfo", projectId ]} );
|
queryClient.invalidateQueries( {queryKey: [ "projectInfo", projectId ]} );
|
||||||
queryClient.invalidateQueries({ queryKey: ["basicProjectNameList"] });
|
queryClient.invalidateQueries({queryKey:['basicProjectNameList']});
|
||||||
|
|
||||||
eventBus.emit("project", {
|
eventBus.emit("project", {
|
||||||
keyword: "Update_Project",
|
keyword: "Update_Project",
|
||||||
@ -424,8 +415,9 @@ export const useUpdateProject = ({ onSuccessCallback }) => {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onError: (error) => {
|
onError: ( error ) =>
|
||||||
console.log(error);
|
{
|
||||||
|
console.log(error)
|
||||||
showToast(error?.message || "Error while updating project", "error");
|
showToast(error?.message || "Error while updating project", "error");
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -438,13 +430,17 @@ export const useUpdateProject = ({ onSuccessCallback }) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useManageProjectInfra = ({ onSuccessCallback }) => {
|
|
||||||
|
export const useManageProjectInfra = ( {onSuccessCallback} ) =>
|
||||||
|
{
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: async ({ infraObject, projectId }) => {
|
mutationFn: async ( {infraObject, projectId} ) =>
|
||||||
|
{
|
||||||
return await ProjectRepository.manageProjectInfra(infraObject);
|
return await ProjectRepository.manageProjectInfra(infraObject);
|
||||||
},
|
},
|
||||||
onSuccess: (data, variables) => {
|
onSuccess: ( data, variables ) =>
|
||||||
|
{
|
||||||
const { projectId } = variables;
|
const { projectId } = variables;
|
||||||
queryClient.invalidateQueries({queryKey:["ProjectInfra", projectId]});
|
queryClient.invalidateQueries({queryKey:["ProjectInfra", projectId]});
|
||||||
if (onSuccessCallback) onSuccessCallback(data,variables);
|
if (onSuccessCallback) onSuccessCallback(data,variables);
|
||||||
@ -455,36 +451,39 @@ export const useManageProjectInfra = ({ onSuccessCallback }) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export const useManageProjectAllocation = ({
|
export const useManageProjectAllocation = ({
|
||||||
onSuccessCallback,
|
onSuccessCallback,
|
||||||
onErrorCallback,
|
onErrorCallback,
|
||||||
}) => {
|
}) => {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
const { mutate, isPending, isSuccess, isError } = useMutation({
|
const {
|
||||||
mutationFn: async ({ items }) => {
|
mutate,
|
||||||
|
isPending,
|
||||||
|
isSuccess,
|
||||||
|
isError,
|
||||||
|
} = useMutation({
|
||||||
|
mutationFn: async ( {items} ) =>
|
||||||
|
{
|
||||||
const response = await ProjectRepository.manageProjectAllocation(items);
|
const response = await ProjectRepository.manageProjectAllocation(items);
|
||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
onSuccess: (data, variables, context) => {
|
onSuccess: (data, variables, context) => {
|
||||||
queryClient.invalidateQueries({
|
queryClient.invalidateQueries({queryKey:['empListByProjectAllocated']});
|
||||||
queryKey: ["empListByProjectAllocated"],
|
queryClient.removeQueries({queryKey:["projectEmployees"]})
|
||||||
});
|
|
||||||
queryClient.removeQueries({ queryKey: ["projectEmployees"] });
|
|
||||||
if (variables?.added) {
|
if (variables?.added) {
|
||||||
showToast("Employee Assigned Successfully", "success");
|
showToast('Employee Assigned Successfully', 'success');
|
||||||
} else {
|
} else {
|
||||||
showToast("Removed Employee Successfully", "success");
|
showToast('Removed Employee Successfully', 'success');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (onSuccessCallback) onSuccessCallback(data, context);
|
if (onSuccessCallback) onSuccessCallback(data, context);
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
const message =
|
const message =
|
||||||
error?.response?.data?.message ||
|
error?.response?.data?.message || error.message || 'Error occurred during API call';
|
||||||
error.message ||
|
showToast(message, 'error');
|
||||||
"Error occurred during API call";
|
|
||||||
showToast(message, "error");
|
|
||||||
if (onErrorCallback) onErrorCallback(error);
|
if (onErrorCallback) onErrorCallback(error);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -497,199 +496,48 @@ export const useManageProjectAllocation = ({
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useManageTask = ({ onSuccessCallback }) => {
|
export const useManageTask = ({onSuccessCallback}) =>
|
||||||
|
{
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const selectedProject = useSelector(
|
|
||||||
(store) => store.localVariables.projectId
|
|
||||||
);
|
|
||||||
return useMutation( {
|
return useMutation( {
|
||||||
mutationFn: async ({
|
mutationFn: async ( payload ) => await ProjectRepository.manageProjectTasks( payload ),
|
||||||
payload,
|
onSuccess: ( data, variables ) =>
|
||||||
PreviousPlannedWork,
|
{
|
||||||
previousCompletedWork,
|
queryClient.invalidateQueries({ queryKey: ["WorkItems"] })
|
||||||
buildingId,
|
|
||||||
floorId,
|
|
||||||
workAreaId,
|
|
||||||
}) => await ProjectRepository.manageProjectTasks(payload),
|
|
||||||
onSuccess: (data, variables) => {
|
|
||||||
const {
|
|
||||||
workAreaId,
|
|
||||||
buildingId,
|
|
||||||
floorId,
|
|
||||||
PreviousPlannedWork,
|
|
||||||
previousCompletedWork,
|
|
||||||
} = variables;
|
|
||||||
queryClient.invalidateQueries({ queryKey: ["WorkItems"] });
|
|
||||||
const getPlannedDelta = (previous, current) => current - previous;
|
|
||||||
queryClient.setQueryData(["ProjectInfra", selectedProject], (oldData) => {
|
|
||||||
if (!oldData) return oldData;
|
|
||||||
const { workAreaId, floorId, buildingId } = variables;
|
|
||||||
const updatedData = JSON.parse(JSON.stringify(oldData));
|
|
||||||
return updatedData.map((building) => {
|
|
||||||
if (building.id !== buildingId) return building;
|
|
||||||
return {
|
|
||||||
...building,
|
|
||||||
floors: building.floors.map((floor) => {
|
|
||||||
if (floor.id !== floorId) return floor;
|
|
||||||
|
|
||||||
return {
|
|
||||||
...floor,
|
|
||||||
workAreas: floor.workAreas.map((area) => {
|
|
||||||
if (area.id !== workAreaId) return area;
|
|
||||||
|
|
||||||
const previousPlanned = PreviousPlannedWork ?? 0;
|
|
||||||
const currentPlanned =
|
|
||||||
data?.data[0]?.workItem.plannedWork ?? 0;
|
|
||||||
|
|
||||||
const plannedWorkDelta = getPlannedDelta(
|
|
||||||
previousPlanned,
|
|
||||||
currentPlanned
|
|
||||||
);
|
|
||||||
const updatedPlannedWork =
|
|
||||||
(area.plannedWork ?? 0) + plannedWorkDelta;
|
|
||||||
const previousCompleted = previousCompletedWork;
|
|
||||||
|
|
||||||
const currentCompleted =
|
|
||||||
data?.data[0]?.workItem.completedWork ?? 0;
|
|
||||||
const completedWorkDelta = getPlannedDelta(
|
|
||||||
previousCompleted,
|
|
||||||
currentCompleted
|
|
||||||
);
|
|
||||||
const updatedCompletedWork =
|
|
||||||
(area.completedWork ?? 0) + completedWorkDelta;
|
|
||||||
return {
|
|
||||||
...area,
|
|
||||||
plannedWork: updatedPlannedWork,
|
|
||||||
completedWork: updatedCompletedWork,
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
queryClient.setQueryData(["ProjectsList"], (projects) => {
|
|
||||||
if (!projects) return projects;
|
|
||||||
|
|
||||||
return projects.map((project) => {
|
|
||||||
if (project.id !== selectedProject) return project;
|
|
||||||
|
|
||||||
const previousPlanned = PreviousPlannedWork ?? 0;
|
|
||||||
const currentPlanned = data?.data[0]?.workItem.plannedWork ?? 0;
|
|
||||||
|
|
||||||
const plannedWorkDelta = getPlannedDelta(
|
|
||||||
previousPlanned,
|
|
||||||
currentPlanned
|
|
||||||
);
|
|
||||||
const updatedPlannedWork =
|
|
||||||
(project.plannedWork ?? 0) + plannedWorkDelta;
|
|
||||||
const previousCompleted = previousCompletedWork;
|
|
||||||
const currentCompleted = data?.data[0]?.workItem.completedWork ?? 0;
|
|
||||||
const completedWorkDelta = getPlannedDelta(
|
|
||||||
previousCompleted,
|
|
||||||
currentCompleted
|
|
||||||
);
|
|
||||||
const updatedCompletedWork =
|
|
||||||
(project.completedWork ?? 0) + completedWorkDelta;
|
|
||||||
return {
|
|
||||||
...project,
|
|
||||||
plannedWork: updatedPlannedWork,
|
|
||||||
completedWork: updatedCompletedWork,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
});
|
|
||||||
if (onSuccessCallback) onSuccessCallback(data);
|
if (onSuccessCallback) onSuccessCallback(data);
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) =>
|
||||||
|
{
|
||||||
const message =
|
const message =
|
||||||
error?.response?.data?.message ||
|
error?.response?.data?.message || error.message || 'Error occurred during API call';
|
||||||
error.message ||
|
showToast(message, 'error');
|
||||||
"Error occurred during API call";
|
}
|
||||||
showToast(message, "error");
|
|
||||||
},
|
})
|
||||||
});
|
}
|
||||||
};
|
|
||||||
|
|
||||||
export const useDeleteProjectTask = (onSuccessCallback) => {
|
export const useDeleteProjectTask = (onSuccessCallback) => {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const selectedProject = useSelector(
|
|
||||||
(store) => store.localVariables.projectId
|
|
||||||
);
|
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: async ({
|
mutationFn: async ( {workItemId, workAreaId} ) =>
|
||||||
workItemId,
|
{
|
||||||
workAreaId,
|
|
||||||
completedTask,
|
|
||||||
plannedTask,
|
|
||||||
}) => {
|
|
||||||
return await ProjectRepository.deleteProjectTask(workItemId);
|
return await ProjectRepository.deleteProjectTask(workItemId);
|
||||||
},
|
},
|
||||||
onSuccess: (_, variables) => {
|
onSuccess: ( _, variables ) =>
|
||||||
const { completedTask, plannedTask, workAreaId, buildingId, floorId } =
|
{
|
||||||
variables;
|
|
||||||
|
|
||||||
queryClient.invalidateQueries({
|
|
||||||
queryKey: ["WorkItems", variables.workAreaId],
|
|
||||||
});
|
|
||||||
|
|
||||||
queryClient.setQueryData(["ProjectInfra", selectedProject], (oldData) => {
|
|
||||||
if (!oldData) return oldData;
|
|
||||||
|
|
||||||
const { workAreaId, floorId, buildingId, plannedTask, completedTask } =
|
|
||||||
variables;
|
|
||||||
|
|
||||||
const updatedData = JSON.parse(JSON.stringify(oldData));
|
|
||||||
|
|
||||||
return updatedData.map((building) => {
|
|
||||||
if (building.id !== buildingId) return building;
|
|
||||||
|
|
||||||
return {
|
|
||||||
...building,
|
|
||||||
floors: building.floors.map((floor) => {
|
|
||||||
if (floor.id !== floorId) return floor;
|
|
||||||
|
|
||||||
return {
|
|
||||||
...floor,
|
|
||||||
workAreas: floor.workAreas.map((area) => {
|
|
||||||
if (area.id !== workAreaId) return area;
|
|
||||||
|
|
||||||
return {
|
|
||||||
...area,
|
|
||||||
plannedWork: (area.plannedWork ?? 0) - plannedTask,
|
|
||||||
completedWork: (area.completedWork ?? 0) - completedTask,
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
queryClient.setQueryData(["ProjectsList"], (projects) => {
|
|
||||||
if (!projects) return projects;
|
|
||||||
|
|
||||||
return projects.map((project) => {
|
|
||||||
if (project.id !== selectedProject) return project;
|
|
||||||
|
|
||||||
return {
|
|
||||||
...project,
|
|
||||||
plannedWork: (project.plannedWork ?? 0) - plannedTask,
|
|
||||||
completedWork: (project.completedWork ?? 0) - completedTask,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
});
|
|
||||||
showToast("Task deleted successfully", "success");
|
showToast("Task deleted successfully", "success");
|
||||||
|
queryClient.invalidateQueries({queryKey:[ "WorkItems",variables.workAreaId]});
|
||||||
if (onSuccessCallback) onSuccessCallback();
|
if (onSuccessCallback) onSuccessCallback();
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
showToast(
|
showToast(
|
||||||
error?.response?.data?.message ||
|
error?.response?.data?.message || error.message || "Failed to delete task",
|
||||||
error.message ||
|
|
||||||
"Failed to delete task",
|
|
||||||
"error"
|
"error"
|
||||||
);
|
);
|
||||||
if (onSuccessCallback) onSuccessCallback();
|
if (onSuccessCallback) onSuccessCallback();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|||||||
import showToast from "../services/toastService";
|
import showToast from "../services/toastService";
|
||||||
import {useSelector} from "react-redux";
|
import {useSelector} from "react-redux";
|
||||||
|
|
||||||
|
|
||||||
// ---------Query---------------------------------
|
// ---------Query---------------------------------
|
||||||
|
|
||||||
export const useTaskList = (projectId, dateFrom, toDate) => {
|
export const useTaskList = (projectId, dateFrom, toDate) => {
|
||||||
@ -27,6 +28,7 @@ export const useTaskList = (projectId, dateFrom, toDate) => {
|
|||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
enabled,
|
enabled,
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return { TaskList, loading, error, refetch };
|
return { TaskList, loading, error, refetch };
|
||||||
@ -73,79 +75,46 @@ export const useAuditStatus = () => {
|
|||||||
const res = await MasterRespository.getAuditStatus();
|
const res = await MasterRespository.getAuditStatus();
|
||||||
return res.data;
|
return res.data;
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return { status, loading, error, refetch };
|
return { status, loading, error, refetch };
|
||||||
};
|
};
|
||||||
|
|
||||||
// -----------------------Mutation------------------------
|
|
||||||
const toDate = new Date().toISOString().split("T")[0];
|
|
||||||
const dateFrom = new Date(Date.now() - 6 * 24 * 60 * 60 * 1000)
|
|
||||||
.toISOString()
|
|
||||||
.split("T")[0];
|
|
||||||
|
|
||||||
export const useReportTask = ({ onSuccessCallback, onErrorCallback } = {}) => {
|
// -----------------------Mutation------------------------
|
||||||
|
const toDate = new Date().toISOString().split('T')[0];
|
||||||
|
const dateFrom = new Date(Date.now() - 6 * 24 * 60 * 60 * 1000).toISOString().split('T')[0];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export const useReportTask = ( {onSuccessCallback, onErrorCallback} = {} ) =>
|
||||||
|
{
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const selectedProject = useSelector(
|
const {
|
||||||
(store) => store.localVariables.projectId
|
mutate,
|
||||||
);
|
isPending,
|
||||||
const { mutate, isPending, isSuccess, isError, error } = useMutation({
|
isSuccess,
|
||||||
mutationFn: async ({ reportData, workAreaId }) => {
|
isError,
|
||||||
|
error,
|
||||||
|
} = useMutation({
|
||||||
|
mutationFn: async ( {reportData,workAreaId} ) =>
|
||||||
|
{
|
||||||
|
debugger
|
||||||
return await TasksRepository.reportTask(reportData);
|
return await TasksRepository.reportTask(reportData);
|
||||||
},
|
},
|
||||||
onSuccess: (data, variables) => {
|
onSuccess: ( data, variables ) =>
|
||||||
const { workAreaId, buildingId, floorId } = variables;
|
{
|
||||||
|
const {workAreaId} = variables;
|
||||||
queryClient.invalidateQueries( {queryKey: [ "taskList" ]} );
|
queryClient.invalidateQueries( {queryKey: [ "taskList" ]} );
|
||||||
queryClient.invalidateQueries( {queryKey: [ "WorkItems", workAreaId ]} );
|
queryClient.invalidateQueries( {queryKey: [ "WorkItems", workAreaId ]} );
|
||||||
queryClient.setQueryData(["ProjectInfra", selectedProject], (oldData) => {
|
queryClient.invalidateQueries( {queryKey: [ 'ProjectsList' ]} );
|
||||||
if (!oldData) return oldData;
|
|
||||||
const { workAreaId, floorId, buildingId } = variables;
|
|
||||||
const updatedData = JSON.parse(JSON.stringify(oldData));
|
|
||||||
|
|
||||||
return updatedData.map((building) => {
|
|
||||||
if (building.id !== buildingId) return building;
|
|
||||||
return {
|
|
||||||
...building,
|
|
||||||
floors: building.floors.map((floor) => {
|
|
||||||
if (floor.id !== floorId) return floor;
|
|
||||||
|
|
||||||
return {
|
|
||||||
...floor,
|
|
||||||
workAreas: floor.workAreas.map((area) => {
|
|
||||||
if (area.id !== workAreaId) return area;
|
|
||||||
return {
|
|
||||||
...area,
|
|
||||||
completedWork:
|
|
||||||
(area.completedWork ?? 0) +
|
|
||||||
(data?.data?.completedTask ?? 0),
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
});
|
|
||||||
});
|
|
||||||
queryClient.setQueryData(["ProjectsList"], (projects) => {
|
|
||||||
if (!projects) return projects;
|
|
||||||
const updatedProject = JSON.parse(JSON.stringify(projects));
|
|
||||||
return updatedProject.map((project) => {
|
|
||||||
if (project.id !== selectedProject) return project;
|
|
||||||
|
|
||||||
return {
|
|
||||||
...project,
|
|
||||||
completedWork:
|
|
||||||
(project.completedWork ?? 0) + (data?.data?.completedTask ?? 0),
|
|
||||||
};
|
|
||||||
});
|
|
||||||
});
|
|
||||||
showToast( "Task Reported Successfully.", "success" );
|
showToast( "Task Reported Successfully.", "success" );
|
||||||
if (onSuccessCallback) onSuccessCallback(data);
|
if (onSuccessCallback) onSuccessCallback(data);
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
const msg =
|
const msg =
|
||||||
error?.response?.data?.message ||
|
error?.response?.data?.message || error.message || "Error occurred during API call";
|
||||||
error.message ||
|
|
||||||
"Error occurred during API call";
|
|
||||||
showToast( msg, "error" );
|
showToast( msg, "error" );
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -176,12 +145,16 @@ export const useSubmitTaskComment = ({ actionAllow, onSuccessCallback }) => {
|
|||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
|
|
||||||
onSuccess: (data, variables) => {
|
onSuccess: ( data,variables ) =>
|
||||||
|
{
|
||||||
|
|
||||||
const workAreaId = variables?.commentsData?.workItem?.workArea?.id;
|
const workAreaId = variables?.commentsData?.workItem?.workArea?.id;
|
||||||
queryClient.invalidateQueries({ queryKey: ["taskList"] });
|
queryClient.invalidateQueries({ queryKey: ["taskList"] });
|
||||||
if (actionAllow) {
|
if (actionAllow) {
|
||||||
showToast( "Review submitted successfully.", "success" );
|
showToast( "Review submitted successfully.", "success" );
|
||||||
} else {
|
|
||||||
|
} else
|
||||||
|
{
|
||||||
showToast("Comment sent successfully.", "success");
|
showToast("Comment sent successfully.", "success");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,10 +162,7 @@ export const useSubmitTaskComment = ({ actionAllow, onSuccessCallback }) => {
|
|||||||
},
|
},
|
||||||
|
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
const msg =
|
const msg = error?.response?.data?.message || error.message || "Error during API call";
|
||||||
error?.response?.data?.message ||
|
|
||||||
error.message ||
|
|
||||||
"Error during API call";
|
|
||||||
showToast(msg, "error");
|
showToast(msg, "error");
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -200,21 +170,22 @@ export const useSubmitTaskComment = ({ actionAllow, onSuccessCallback }) => {
|
|||||||
return { submitComment: mutate, isPending };
|
return { submitComment: mutate, isPending };
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useCreateTask = ({ onSuccessCallback, onErrorCallback } = {}) => {
|
export const useCreateTask = ( {onSuccessCallback, onErrorCallback} = {} ) =>
|
||||||
|
{
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: async ({payload,workAreaId}) => {
|
mutationFn: async ({payload,workAreaId}) => {
|
||||||
return await TasksRepository.assignTask(payload);
|
return await TasksRepository.assignTask(payload);
|
||||||
},
|
},
|
||||||
onSuccess: (_, variables) => {
|
onSuccess: ( _, variables ) =>
|
||||||
|
{
|
||||||
queryClient.invalidateQueries( {queryKey: [ "taskList" ]} );
|
queryClient.invalidateQueries( {queryKey: [ "taskList" ]} );
|
||||||
queryClient.invalidateQueries({
|
queryClient.invalidateQueries( {queryKey: [ "WorkItems", variables?.workAreaId ]} );
|
||||||
queryKey: ["WorkItems", variables?.workAreaId],
|
|
||||||
});
|
|
||||||
showToast( "Task Assigned Successfully.", "success" );
|
showToast( "Task Assigned Successfully.", "success" );
|
||||||
if (onSuccessCallback) onSuccessCallback(variables);
|
if (onSuccessCallback) onSuccessCallback(variables);
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: ( error ) =>
|
||||||
|
{
|
||||||
showToast("Something went wrong. Please try again.", "error");
|
showToast("Something went wrong. Please try again.", "error");
|
||||||
if (onErrorCallback) onErrorCallback(error);
|
if (onErrorCallback) onErrorCallback(error);
|
||||||
},
|
},
|
||||||
|
|||||||
@ -14,8 +14,6 @@ import GlobalModel from "../../components/common/GlobalModel";
|
|||||||
import AssignTask from "../../components/Project/AssignTask";
|
import AssignTask from "../../components/Project/AssignTask";
|
||||||
import SubTask from "../../components/Activities/SubTask";
|
import SubTask from "../../components/Activities/SubTask";
|
||||||
import {formatNumber} from "../../utils/dateUtils";
|
import {formatNumber} from "../../utils/dateUtils";
|
||||||
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
|
||||||
import { APPROVE_TASK, ASSIGN_REPORT_TASK } from "../../utils/constants";
|
|
||||||
|
|
||||||
const DailyTask = () => {
|
const DailyTask = () => {
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
@ -34,8 +32,6 @@ const DailyTask = () => {
|
|||||||
|
|
||||||
|
|
||||||
const [dateRange, setDateRange] = useState({ startDate: "", endDate: "" });
|
const [dateRange, setDateRange] = useState({ startDate: "", endDate: "" });
|
||||||
const ApprovedTaskRights = useHasUserPermission(APPROVE_TASK)
|
|
||||||
const ReportTaskRights = useHasUserPermission(ASSIGN_REPORT_TASK)
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
TaskList,
|
TaskList,
|
||||||
@ -390,7 +386,6 @@ const DailyTask = () => {
|
|||||||
</td>
|
</td>
|
||||||
<td className="text-center">
|
<td className="text-center">
|
||||||
<div className="d-flex justify-content-end">
|
<div className="d-flex justify-content-end">
|
||||||
{ ReportTaskRights &&
|
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className={`btn btn-xs btn-primary ${
|
className={`btn btn-xs btn-primary ${
|
||||||
@ -405,8 +400,7 @@ const DailyTask = () => {
|
|||||||
>
|
>
|
||||||
Report
|
Report
|
||||||
</button>
|
</button>
|
||||||
}
|
{task.reportedDate && (
|
||||||
{(ApprovedTaskRights && task.reportedDate ) && (
|
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className={`btn btn-xs btn-warning ${
|
className={`btn btn-xs btn-warning ${
|
||||||
|
|||||||
@ -260,7 +260,7 @@ const Directory = ({ IsPage = true, prefernceContacts }) => {
|
|||||||
}, [prefernceContacts]);
|
}, [prefernceContacts]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={IsPage ? "container-fluid":""}>
|
<div className="container-fluid">
|
||||||
{IsPage && (
|
{IsPage && (
|
||||||
<Breadcrumb
|
<Breadcrumb
|
||||||
data={[
|
data={[
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import { useEmployeesAllOrByProjectId, useSuspendEmployee } from "../../hooks/us
|
|||||||
import { useProjects } from "../../hooks/useProjects";
|
import { useProjects } from "../../hooks/useProjects";
|
||||||
import { useProfile } from "../../hooks/useProfile";
|
import { useProfile } from "../../hooks/useProfile";
|
||||||
import { hasUserPermission } from "../../utils/authUtils";
|
import { hasUserPermission } from "../../utils/authUtils";
|
||||||
import { ITEMS_PER_PAGE, MANAGE_EMPLOYEES, VIEW_ALL_EMPLOYEES, VIEW_TEAM_MEMBERS } from "../../utils/constants";
|
import { ITEMS_PER_PAGE, MANAGE_EMPLOYEES } from "../../utils/constants";
|
||||||
import { clearCacheKey } from "../../slices/apiDataManager";
|
import { clearCacheKey } from "../../slices/apiDataManager";
|
||||||
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
||||||
import SuspendEmp from "../../components/Employee/SuspendEmp"; // Keep if you use SuspendEmp
|
import SuspendEmp from "../../components/Employee/SuspendEmp"; // Keep if you use SuspendEmp
|
||||||
@ -56,8 +56,6 @@ const EmployeeList = () => {
|
|||||||
const [IsDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
|
const [IsDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
|
||||||
const [selectedEmpFordelete, setSelectedEmpFordelete] = useState(null);
|
const [selectedEmpFordelete, setSelectedEmpFordelete] = useState(null);
|
||||||
const [ employeeLodaing, setemployeeLodaing ] = useState( false );
|
const [ employeeLodaing, setemployeeLodaing ] = useState( false );
|
||||||
const ViewTeamMember = useHasUserPermission(VIEW_TEAM_MEMBERS)
|
|
||||||
const ViewAllEmployee = useHasUserPermission(VIEW_ALL_EMPLOYEES)
|
|
||||||
const {
|
const {
|
||||||
mutate: suspendEmployee,
|
mutate: suspendEmployee,
|
||||||
isPending: empLodaing
|
isPending: empLodaing
|
||||||
@ -122,6 +120,23 @@ useEffect(() => {
|
|||||||
setIsCreateModalOpen(true);
|
setIsCreateModalOpen(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// const closeModal = () => {
|
||||||
|
// setIsCreateModalOpen(false);
|
||||||
|
|
||||||
|
// const modalElement = document.getElementById("managerole-modal");
|
||||||
|
// if (modalElement && !showModal) {
|
||||||
|
// modalElement.classList.remove("show");
|
||||||
|
// modalElement.style.display = "none";
|
||||||
|
// document.body.classList.remove("modal-open");
|
||||||
|
// document.querySelector(".modal-backdrop")?.remove();
|
||||||
|
// }
|
||||||
|
// setShowModal(false);
|
||||||
|
// clearCacheKey("employeeProfile");
|
||||||
|
// recallEmployeeData(showInactive, showAllEmployees ? null : selectedProjectId); // Use selectedProjectId here
|
||||||
|
// };
|
||||||
|
// const handleShow = () => setShowModal(true);
|
||||||
|
// const handleClose = () => setShowModal( false );
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!loading && Array.isArray(employees)) {
|
if (!loading && Array.isArray(employees)) {
|
||||||
const sorted = [...employees].sort((a, b) => {
|
const sorted = [...employees].sort((a, b) => {
|
||||||
@ -281,9 +296,7 @@ const handleAllEmployeesToggle = (e) => {
|
|||||||
{ label: "Employees", link: null },
|
{ label: "Employees", link: null },
|
||||||
]}
|
]}
|
||||||
></Breadcrumb>
|
></Breadcrumb>
|
||||||
|
<div className="row">
|
||||||
|
|
||||||
{ViewTeamMember ? (<div className="row">
|
|
||||||
<div className="card ">
|
<div className="card ">
|
||||||
<div className="card-datatable table-responsive pt-2">
|
<div className="card-datatable table-responsive pt-2">
|
||||||
|
|
||||||
@ -296,7 +309,6 @@ const handleAllEmployeesToggle = (e) => {
|
|||||||
{/* Switches: All Employees + Inactive */}
|
{/* Switches: All Employees + Inactive */}
|
||||||
<div className="d-flex flex-wrap align-items-center gap-3">
|
<div className="d-flex flex-wrap align-items-center gap-3">
|
||||||
{/* All Employees Switch */}
|
{/* All Employees Switch */}
|
||||||
{ViewAllEmployee && (
|
|
||||||
<div className="form-check form-switch text-start">
|
<div className="form-check form-switch text-start">
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
@ -310,7 +322,6 @@ const handleAllEmployeesToggle = (e) => {
|
|||||||
All Employees
|
All Employees
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
) }
|
|
||||||
|
|
||||||
{/* Show Inactive Employees Switch */}
|
{/* Show Inactive Employees Switch */}
|
||||||
{showAllEmployees && (
|
{showAllEmployees && (
|
||||||
@ -691,15 +702,8 @@ const handleAllEmployeesToggle = (e) => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>):(
|
|
||||||
<div className="card">
|
|
||||||
<div className="text-center">
|
|
||||||
<i className="fa-solid fa-triangle-exclamation fs-5"></i>
|
|
||||||
<p>Access Denied: You don't have permission to perform this action. !</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -265,8 +265,8 @@ 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" style={{ minHeight: "200px" }}>
|
||||||
<div className="table-responsive text-nowrap py-2 " style={{minHeight:"400px"}}>
|
<div className="table-responsive text-nowrap py-2">
|
||||||
<table className="table m-3">
|
<table className="table m-3">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -293,10 +293,6 @@ const ProjectList = () => {
|
|||||||
id: "b74da4c2-d07e-46f2-9919-e75e49b12731",
|
id: "b74da4c2-d07e-46f2-9919-e75e49b12731",
|
||||||
label: "Active",
|
label: "Active",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
id: "cdad86aa-8a56-4ff4-b633-9c629057dfef",
|
|
||||||
label:"In Progress"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: "603e994b-a27f-4e5d-a251-f3d69b0498ba",
|
id: "603e994b-a27f-4e5d-a251-f3d69b0498ba",
|
||||||
label: "On Hold",
|
label: "On Hold",
|
||||||
@ -318,9 +314,7 @@ const ProjectList = () => {
|
|||||||
checked={selectedStatuses.includes(id)}
|
checked={selectedStatuses.includes(id)}
|
||||||
onChange={() => handleStatusChange(id)}
|
onChange={() => handleStatusChange(id)}
|
||||||
/>
|
/>
|
||||||
<label className="form-check-label">
|
<label className="form-check-label">{label}</label>
|
||||||
{label}
|
|
||||||
</label>
|
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
@ -336,11 +330,22 @@ const ProjectList = () => {
|
|||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody className="table-border-bottom-0 overflow-auto ">
|
<tbody className="table-border-bottom-0" style={{ height: "200px" }}>
|
||||||
{currentItems.length === 0 ? (
|
{currentItems.length === 0 ? (
|
||||||
<tr className="text-center">
|
<tr>
|
||||||
<td colSpan="12" rowSpan='12'style={{height:"200px"}} >
|
<td
|
||||||
No projects found
|
colSpan="12"
|
||||||
|
className="text-center"
|
||||||
|
style={{
|
||||||
|
verticalAlign: "middle",
|
||||||
|
height: "200px",
|
||||||
|
paddingTop: 0,
|
||||||
|
paddingBottom: 0,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div className="d-flex flex-column justify-content-center align-items-center h-100">
|
||||||
|
<p className="mb-0">No projects found</p>
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
) : (
|
) : (
|
||||||
@ -354,8 +359,8 @@ const ProjectList = () => {
|
|||||||
)}
|
)}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>{" "}
|
</div>
|
||||||
</div>{" "}
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="row">
|
<div className="row">
|
||||||
@ -393,11 +398,7 @@ const ProjectList = () => {
|
|||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
<li
|
<li className={`page-item ${currentPage === totalPages && "disabled"}`}>
|
||||||
className={`page-item ${
|
|
||||||
currentPage === totalPages && "disabled"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
<button
|
<button
|
||||||
className="page-link"
|
className="page-link"
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
@ -410,6 +411,7 @@ const ProjectList = () => {
|
|||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -11,11 +11,6 @@ export const VIEW_PROJECTS = "6ea44136-987e-44ba-9e5d-1cf8f5837ebc"
|
|||||||
|
|
||||||
export const MANAGE_EMPLOYEES = "a97d366a-c2bb-448d-be93-402bd2324566"
|
export const MANAGE_EMPLOYEES = "a97d366a-c2bb-448d-be93-402bd2324566"
|
||||||
|
|
||||||
export const VIEW_ALL_EMPLOYEES = "60611762-7f8a-4fb5-b53f-b1139918796b"
|
|
||||||
|
|
||||||
export const VIEW_TEAM_MEMBERS = "b82d2b7e-0d52-45f3-997b-c008ea460e7f"
|
|
||||||
|
|
||||||
|
|
||||||
export const MANAGE_PROJECT_INFRA = "cf2825ad-453b-46aa-91d9-27c124d63373"
|
export const MANAGE_PROJECT_INFRA = "cf2825ad-453b-46aa-91d9-27c124d63373"
|
||||||
|
|
||||||
export const VIEW_PROJECT_INFRA = "8d7cc6e3-9147-41f7-aaa7-fa507e450bd4"
|
export const VIEW_PROJECT_INFRA = "8d7cc6e3-9147-41f7-aaa7-fa507e450bd4"
|
||||||
@ -29,8 +24,6 @@ export const INFRASTRUCTURE = "9666de86-d7c7-4d3d-acaa-fcd6d6b81f3c";
|
|||||||
|
|
||||||
export const MANAGE_TASK = "08752f33-3b29-4816-b76b-ea8a968ed3c5"
|
export const MANAGE_TASK = "08752f33-3b29-4816-b76b-ea8a968ed3c5"
|
||||||
|
|
||||||
export const APPROVE_TASK = "db4e40c5-2ba9-4b6d-b8a6-a16a250ff99c"
|
|
||||||
|
|
||||||
export const VIEW_TASK = "9fcc5f87-25e3-4846-90ac-67a71ab92e3c"
|
export const VIEW_TASK = "9fcc5f87-25e3-4846-90ac-67a71ab92e3c"
|
||||||
|
|
||||||
export const ASSIGN_REPORT_TASK = "6a32379b-8b3f-49a6-8c48-4b7ac1b55dc2"
|
export const ASSIGN_REPORT_TASK = "6a32379b-8b3f-49a6-8c48-4b7ac1b55dc2"
|
||||||
|
|||||||
@ -70,12 +70,3 @@ export const formatNumber = (num) => {
|
|||||||
export const formatUTCToLocalTime = (datetime) =>{
|
export const formatUTCToLocalTime = (datetime) =>{
|
||||||
return moment.utc(datetime).local().format("MMMM DD, YYYY [at] hh:mm A");
|
return moment.utc(datetime).local().format("MMMM DD, YYYY [at] hh:mm A");
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getCompletionPercentage = (completedWork, plannedWork)=> {
|
|
||||||
if (!plannedWork || plannedWork === 0) return 0;
|
|
||||||
|
|
||||||
const percentage = (completedWork / plannedWork) * 100;
|
|
||||||
const clamped = Math.min(Math.max(percentage, 0), 100);
|
|
||||||
|
|
||||||
return clamped.toFixed(2);
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user