|
@@ -118,7 +114,6 @@ const Regularization = ({ handleRequest }) => {
: "--"}
|
- {/* */}
{
const [ projectInfo, setProjectInfo ] = useState( projectData );
@@ -22,6 +24,7 @@ const ProjectCard = ({ projectData, recall }) => {
);
const [showModal, setShowModal] = useState(false);
const navigate = useNavigate();
+ const dispatch = useDispatch()
const ManageProject = useHasUserPermission(MANAGE_PROJECT);
const {
mutate: updateProject,
@@ -57,6 +60,7 @@ const ProjectCard = ({ projectData, recall }) => {
const handleClose = () => setShowModal(false);
const handleViewProject = () => {
+ dispatch(setProjectId(projectInfo.id))
navigate(`/projects/details`);
};
@@ -71,7 +75,6 @@ const ProjectCard = ({ projectData, recall }) => {
return (
<>
-
{showModal && projects_Details && (
{
};
// EmployeeList.jsx
-export const useEmployeesAllOrByProjectId = (projectId, showInactive) => {
- const isAllEmployees = !projectId && projectId !== undefined;
+export const useEmployeesAllOrByProjectId = (showAllEmployees ,projectId,
+ showInactive) => {
- const queryKey = isAllEmployees
- ? ['allEmployees', showInactive]
- : ['projectEmployees', projectId];
+
+const queryKey = showAllEmployees
+ ? ['allEmployees', showInactive]
+ : ['projectEmployees', projectId, showInactive];
const queryFn = async () => {
- if (isAllEmployees) {
+ if (showAllEmployees) {
const res = await EmployeeRepository.getAllEmployeeList(showInactive);
return res.data;
} else {
+ if (!projectId) return [];
const res = await EmployeeRepository.getEmployeeListByproject(projectId);
return res.data;
}
@@ -137,7 +139,7 @@ export const useEmployeesAllOrByProjectId = (projectId, showInactive) => {
} = useQuery({
queryKey,
queryFn,
- enabled: isAllEmployees || !!projectId,
+ enabled:typeof showInactive === "boolean" && (showAllEmployees || !!projectId),
});
return {
diff --git a/src/pages/employee/EmployeeList.jsx b/src/pages/employee/EmployeeList.jsx
index 09a820da..e091676f 100644
--- a/src/pages/employee/EmployeeList.jsx
+++ b/src/pages/employee/EmployeeList.jsx
@@ -51,7 +51,7 @@ const EmployeeList = () => {
const { employees, loading, setLoading, error, recallEmployeeData } =
useEmployeesAllOrByProjectId(
- showAllEmployees ? null : selectedProjectId,
+ showAllEmployees ,selectedProjectId,
showInactive
);
@@ -153,13 +153,7 @@ const EmployeeList = () => {
}
};
- const handleToggle = (e) => {
- setShowInactive(e.target.checked);
- recallEmployeeData(
- e.target.checked,
- showAllEmployees ? null : selectedProjectId
- ); // Use selectedProjectId here
- };
+
const handleAllEmployeesToggle = (e) => {
const isChecked = e.target.checked;
@@ -340,7 +334,7 @@ const EmployeeList = () => {
role="switch"
id="inactiveEmployeesCheckbox"
checked={showInactive}
- onChange={handleToggle}
+ onChange={()=> setShowInactive(e.target.checked)}
/>
|