Issues_Jun_3W #260
@ -8,6 +8,7 @@ import moment from "moment";
|
||||
import usePagination from "../../hooks/usePagination";
|
||||
import eventBus from "../../services/eventBus";
|
||||
import { cacheData, clearCacheKey } from "../../slices/apiDataManager";
|
||||
import { ITEMS_PER_PAGE } from "../../utils/constants";
|
||||
|
||||
const Regularization = ({ handleRequest }) => {
|
||||
var selectedProject = useSelector((store) => store.localVariables.projectId);
|
||||
@ -44,7 +45,7 @@ const Regularization = ({ handleRequest }) => {
|
||||
|
||||
const { currentPage, totalPages, currentItems, paginate } = usePagination(
|
||||
filteredData,
|
||||
20
|
||||
ITEMS_PER_PAGE
|
||||
);
|
||||
useEffect(() => {
|
||||
eventBus.on("regularization", handler);
|
||||
@ -85,15 +86,10 @@ const Regularization = ({ handleRequest }) => {
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{/* {loading && (
|
||||
<td colSpan={6} className="text-center py-5">
|
||||
Loading...
|
||||
</td>
|
||||
)} */}
|
||||
|
||||
{!loading &&
|
||||
(regularizes?.length > 0 ? (
|
||||
regularizes?.map((att, index) => (
|
||||
(currentItems?.length > 0 ? (
|
||||
currentItems?.map((att, index) => (
|
||||
<tr key={index}>
|
||||
<td colSpan={2}>
|
||||
<div className="d-flex justify-content-start align-items-center">
|
||||
@ -118,7 +114,6 @@ const Regularization = ({ handleRequest }) => {
|
||||
: "--"}
|
||||
</td>
|
||||
<td className="text-center ">
|
||||
{/* <div className='d-flex justify-content-center align-items-center gap-3'> */}
|
||||
<RegularizationActions
|
||||
attendanceData={att}
|
||||
handleRequest={handleRequest}
|
||||
|
||||
@ -14,6 +14,8 @@ import {
|
||||
getProjectStatusName,
|
||||
} from "../../utils/projectStatus";
|
||||
import GlobalModel from "../common/GlobalModel";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { setProjectId } from "../../slices/localVariablesSlice";
|
||||
|
||||
const ProjectCard = ({ projectData, recall }) => {
|
||||
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 && (
|
||||
<GlobalModel isOpen={showModal} closeModal={handleClose}>
|
||||
<ManageProjectInfo
|
||||
|
||||
@ -112,18 +112,20 @@ export const useEmployeesByProject = (projectId) => {
|
||||
};
|
||||
|
||||
// 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 {
|
||||
|
||||
@ -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)}
|
||||
/>
|
||||
<label
|
||||
className="form-check-label ms-0"
|
||||
|
||||
@ -20,8 +20,11 @@ import showToast from "../../services/toastService";
|
||||
import { getCachedData, cacheData } from "../../slices/apiDataManager";
|
||||
import GlobalModel from "../../components/common/GlobalModel";
|
||||
import {formatNumber} from "../../utils/dateUtils";
|
||||
import { setProjectId } from "../../slices/localVariablesSlice";
|
||||
import { useDispatch } from "react-redux";
|
||||
|
||||
const ProjectListView = ({ projectData, recall }) => {
|
||||
const dispatch = useDispatch()
|
||||
const [projectInfo, setProjectInfo] = useState(projectData);
|
||||
const { projects_Details, loading, error, refetch } = useProjectDetails(
|
||||
projectInfo?.id,false
|
||||
@ -89,7 +92,10 @@ const ProjectListView = ({ projectData, recall }) => {
|
||||
<td className="text-start" colSpan={5}>
|
||||
<span
|
||||
className="text-primary cursor-pointer"
|
||||
onClick={() => navigate(`/projects/details`)}
|
||||
onClick={() => {
|
||||
dispatch(setProjectId(projectInfo.id))
|
||||
navigate(`/projects/details`)
|
||||
}}
|
||||
>
|
||||
{projectInfo.shortName
|
||||
? `${projectInfo.name} (${projectInfo.shortName})`
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user