feature/IO-3291-Tasks-Notifications: Checkpoint
This commit is contained in:
@@ -6,11 +6,10 @@ import { selectBodyshop, selectCurrentUser } from "../../redux/user/user.selecto
|
||||
import { useSocket } from "../../contexts/SocketIO/useSocket";
|
||||
import { useIsEmployee } from "../../utils/useIsEmployee";
|
||||
import TaskCenterComponent from "./task-center.component";
|
||||
import dayjs from "../../utils/day";
|
||||
import { setModalContext } from "../../redux/modals/modals.actions";
|
||||
import { QUERY_MY_ACTIVE_TASKS_PAGINATED } from "../../graphql/tasks.queries";
|
||||
|
||||
const POLL_INTERVAL = 60; // seconds
|
||||
const POLL_INTERVAL = 60 * 1000; // milliseconds
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
@@ -31,11 +30,7 @@ const TaskCenterContainer = ({ visible, onClose, bodyshop, currentUser, setTaskU
|
||||
return employee?.id || null;
|
||||
}, [bodyshop, currentUser]);
|
||||
|
||||
const {
|
||||
data,
|
||||
loading: queryLoading,
|
||||
fetchMore
|
||||
} = useQuery(QUERY_MY_ACTIVE_TASKS_PAGINATED, {
|
||||
const { data, loading, fetchMore } = useQuery(QUERY_MY_ACTIVE_TASKS_PAGINATED, {
|
||||
variables: {
|
||||
bodyshop: bodyshop?.id,
|
||||
assigned_to: assignedToId,
|
||||
@@ -45,7 +40,7 @@ const TaskCenterContainer = ({ visible, onClose, bodyshop, currentUser, setTaskU
|
||||
},
|
||||
skip: !bodyshop?.id || !assignedToId || !isEmployee || !currentUser?.email,
|
||||
fetchPolicy: "cache-and-network",
|
||||
pollInterval: isConnected ? 0 : dayjs.duration(POLL_INTERVAL, "seconds").asMilliseconds(),
|
||||
pollInterval: isConnected ? 0 : POLL_INTERVAL,
|
||||
onError: (error) => {
|
||||
console.error("Query error:", error);
|
||||
}
|
||||
@@ -91,11 +86,12 @@ const TaskCenterContainer = ({ visible, onClose, bodyshop, currentUser, setTaskU
|
||||
visible={visible}
|
||||
onClose={onClose}
|
||||
tasks={tasks}
|
||||
loading={queryLoading}
|
||||
loading={loading}
|
||||
onTaskClick={handleTaskClick}
|
||||
onLoadMore={handleLoadMore}
|
||||
totalTasks={data?.tasks_aggregate?.aggregate?.count}
|
||||
totalTasks={data?.tasks_aggregate?.aggregate?.count || 0}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(TaskCenterContainer);
|
||||
|
||||
Reference in New Issue
Block a user