react-query-v2 : react-query intergrated inside attendance and gallery module #270
@ -188,7 +188,7 @@ const Attendance = ({ getRole, handleModalData }) => {
|
|||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
{!attendance && (
|
{!attendance && (
|
||||||
<span>No employees assigned to the project</span>
|
<span className="text-secondary m-4">No employees assigned to the project!</span>
|
||||||
)}
|
)}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -8,8 +8,10 @@ import moment from "moment";
|
|||||||
import usePagination from "../../hooks/usePagination";
|
import usePagination from "../../hooks/usePagination";
|
||||||
import eventBus from "../../services/eventBus";
|
import eventBus from "../../services/eventBus";
|
||||||
import { cacheData, clearCacheKey } from "../../slices/apiDataManager";
|
import { cacheData, clearCacheKey } from "../../slices/apiDataManager";
|
||||||
|
import { useQueryClient } from "@tanstack/react-query";
|
||||||
|
|
||||||
const Regularization = ({ handleRequest }) => {
|
const Regularization = ({ handleRequest }) => {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
var selectedProject = useSelector((store) => store.localVariables.projectId);
|
var selectedProject = useSelector((store) => store.localVariables.projectId);
|
||||||
const [regularizesList, setregularizedList] = useState([]);
|
const [regularizesList, setregularizedList] = useState([]);
|
||||||
const { regularizes, loading, error, refetch } =
|
const { regularizes, loading, error, refetch } =
|
||||||
@ -28,14 +30,25 @@ const Regularization = ({ handleRequest }) => {
|
|||||||
const handler = useCallback(
|
const handler = useCallback(
|
||||||
(msg) => {
|
(msg) => {
|
||||||
if (selectedProject == msg.projectId) {
|
if (selectedProject == msg.projectId) {
|
||||||
const updatedAttendance = regularizes?.filter(
|
// const updatedAttendance = regularizes?.filter(
|
||||||
(item) => item.id !== msg.response.id
|
// (item) => item.id !== msg.response.id
|
||||||
);
|
// );
|
||||||
cacheData("regularizedList", {
|
// cacheData("regularizedList", {
|
||||||
data: updatedAttendance,
|
// data: updatedAttendance,
|
||||||
projectId: selectedProject,
|
// projectId: selectedProject,
|
||||||
});
|
// });
|
||||||
refetch();
|
// refetch();
|
||||||
|
|
||||||
|
queryClient.setQueryData(
|
||||||
|
["regularizedList", selectedProject],
|
||||||
|
(oldData) => {
|
||||||
|
if (!oldData) {
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["regularizedList"] });
|
||||||
|
}
|
||||||
|
return oldData.filter((record) => record.id !== msg.response.id);
|
||||||
|
}
|
||||||
|
),
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["attendanceLogs"] });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[selectedProject, regularizes]
|
[selectedProject, regularizes]
|
||||||
@ -123,7 +136,10 @@ const Regularization = ({ handleRequest }) => {
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
) : (
|
) : (
|
||||||
<div className="my-4"> <span className="text-muted">No Requests Found</span></div>
|
<div className="my-4">
|
||||||
|
{" "}
|
||||||
|
<span className="text-secondary">No Requests Found !</span>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
{!loading && totalPages > 1 && (
|
{!loading && totalPages > 1 && (
|
||||||
<nav aria-label="Page ">
|
<nav aria-label="Page ">
|
||||||
|
@ -29,7 +29,7 @@ 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 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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user