feature/IO-3291-Tasks-Notifications: Final

This commit is contained in:
Dave Richer
2025-07-11 13:38:19 -04:00
parent 4dcfb382a9
commit e0b937474d
8 changed files with 54 additions and 16 deletions

View File

@@ -90,7 +90,7 @@ const TaskCenterComponent = forwardRef(
<div className="task-row-container">
<div className="task-title">{task.title}</div>
<div className="task-ro-number">
{t("notifications.labels.ro-number", {
{t("tasks.labels.ro-number", {
ro_number: task.job?.ro_number || t("general.labels.na")
})}
</div>
@@ -110,7 +110,7 @@ const TaskCenterComponent = forwardRef(
<div className="task-header">
<h3>{t("tasks.labels.my_tasks_center")}</h3>
</div>
<div className="error-message">{t("errors.tasks_load_failed")}</div>
<div className="error-message">{t("tasks.errors.load_failed")}</div>
</div>
);
}

View File

@@ -3,15 +3,12 @@ import { useQuery } from "@apollo/client";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { selectBodyshop, selectCurrentUser } from "../../redux/user/user.selectors";
import { useSocket } from "../../contexts/SocketIO/useSocket";
import { INITIAL_TASKS, TASKS_CENTER_POLL_INTERVAL, useSocket } from "../../contexts/SocketIO/useSocket";
import { useIsEmployee } from "../../utils/useIsEmployee";
import TaskCenterComponent from "./task-center.component";
import { setModalContext } from "../../redux/modals/modals.actions";
import { QUERY_TASKS_NO_DUE_DATE_PAGINATED, QUERY_TASKS_WITH_DUE_DATES } from "../../graphql/tasks.queries";
const POLL_INTERVAL = 60 * 1000; // milliseconds
const LIMIT = 5; // Tasks per page for no-due-date tasks
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop,
currentUser: selectCurrentUser
@@ -51,7 +48,7 @@ const TaskCenterContainer = ({
},
skip: !bodyshop?.id || !assignedToId || !isEmployee || !currentUser?.email,
fetchPolicy: "cache-and-network",
pollInterval: isConnected ? 0 : POLL_INTERVAL
pollInterval: isConnected ? 0 : TASKS_CENTER_POLL_INTERVAL
});
// Query 2: Tasks with no due date (paginated)
@@ -64,13 +61,13 @@ const TaskCenterContainer = ({
variables: {
bodyshop: bodyshop?.id,
assigned_to: assignedToId,
order: [{ created_at: "desc" }],
limit: LIMIT,
order: [{ priority: "asc" }, { created_at: "desc" }],
limit: INITIAL_TASKS, // Adjust this constant as needed
offset: 0
},
skip: !bodyshop?.id || !assignedToId || !isEmployee || !currentUser?.email,
fetchPolicy: "cache-and-network",
pollInterval: isConnected ? 0 : POLL_INTERVAL
pollInterval: isConnected ? 0 : TASKS_CENTER_POLL_INTERVAL
});
// Combine tasks from both queries