diff --git a/client/src/components/header/header.component.jsx b/client/src/components/header/header.component.jsx
index f1f480821..3312bf9f4 100644
--- a/client/src/components/header/header.component.jsx
+++ b/client/src/components/header/header.component.jsx
@@ -9,7 +9,7 @@ import { useTranslation } from "react-i18next";
import { FaTasks } from "react-icons/fa";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
-import { useSocket } from "../../contexts/SocketIO/useSocket.js";
+import { TASKS_CENTER_POLL_INTERVAL, useSocket } from "../../contexts/SocketIO/useSocket.js";
import { GET_UNREAD_COUNT } from "../../graphql/notifications.queries.js";
import { QUERY_MY_TASKS_COUNT } from "../../graphql/tasks.queries.js";
import { selectRecentItems, selectSelectedHeader } from "../../redux/application/application.selectors";
@@ -76,7 +76,7 @@ function useIncompleteTaskCount(assignedToId, bodyshopId, isEmployee, isConnecte
variables: { assigned_to: assignedToId, bodyshopid: bodyshopId },
skip: !assignedToId || !bodyshopId || !isEmployee,
fetchPolicy: "network-only",
- pollInterval: isConnected ? 0 : day.duration(60, "seconds").asMilliseconds()
+ pollInterval: isConnected ? 0 : TASKS_CENTER_POLL_INTERVAL
});
const incompleteTaskCount = taskCountData?.tasks_aggregate?.aggregate?.count ?? 0;
diff --git a/client/src/components/task-center/task-center.component.jsx b/client/src/components/task-center/task-center.component.jsx
index 0c2b8e899..8b269f7b7 100644
--- a/client/src/components/task-center/task-center.component.jsx
+++ b/client/src/components/task-center/task-center.component.jsx
@@ -90,7 +90,7 @@ const TaskCenterComponent = forwardRef(
{task.title}
- {t("notifications.labels.ro-number", {
+ {t("tasks.labels.ro-number", {
ro_number: task.job?.ro_number || t("general.labels.na")
})}
@@ -110,7 +110,7 @@ const TaskCenterComponent = forwardRef(
{t("tasks.labels.my_tasks_center")}
-
{t("errors.tasks_load_failed")}
+
{t("tasks.errors.load_failed")}
);
}
diff --git a/client/src/components/task-center/task-center.container.jsx b/client/src/components/task-center/task-center.container.jsx
index 121fe1768..9291b600d 100644
--- a/client/src/components/task-center/task-center.container.jsx
+++ b/client/src/components/task-center/task-center.container.jsx
@@ -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
diff --git a/client/src/contexts/SocketIO/useSocket.js b/client/src/contexts/SocketIO/useSocket.js
index d9a6f9b84..239e391de 100644
--- a/client/src/contexts/SocketIO/useSocket.js
+++ b/client/src/contexts/SocketIO/useSocket.js
@@ -3,6 +3,8 @@ import { createContext, useContext } from "react";
const SocketContext = createContext(null);
const INITIAL_NOTIFICATIONS = 10;
+const INITIAL_TASKS = 5;
+const TASKS_CENTER_POLL_INTERVAL = 60 * 60 * 1000; // 1 hour in milliseconds
const useSocket = () => {
const context = useContext(SocketContext);
@@ -10,4 +12,4 @@ const useSocket = () => {
return context;
};
-export { SocketContext, INITIAL_NOTIFICATIONS, useSocket };
+export { SocketContext, INITIAL_NOTIFICATIONS, INITIAL_TASKS, TASKS_CENTER_POLL_INTERVAL, useSocket };
diff --git a/client/src/graphql/tasks.queries.js b/client/src/graphql/tasks.queries.js
index c9496fcea..76eaf452c 100644
--- a/client/src/graphql/tasks.queries.js
+++ b/client/src/graphql/tasks.queries.js
@@ -68,7 +68,7 @@ export const PARTIAL_TASK_FIELDS = gql`
`;
export const PARTIAL_TASK_CENTER_FIELDS = gql`
- fragment TaskFields on tasks {
+ fragment PartialTaskFields on tasks {
id
title
description
@@ -103,7 +103,7 @@ export const QUERY_TASKS_WITH_DUE_DATES = gql`
}
order_by: $order
) {
- ...TaskFields
+ ...PartialTaskFields
}
}
`;
@@ -128,7 +128,7 @@ export const QUERY_TASKS_NO_DUE_DATE_PAGINATED = gql`
limit: $limit
offset: $offset
) {
- ...TaskFields
+ ...PartialTaskFields
}
tasks_aggregate(
where: {
diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json
index b56a6e5ee..088c69d33 100644
--- a/client/src/translations/en_us/common.json
+++ b/client/src/translations/en_us/common.json
@@ -3295,6 +3295,16 @@
}
},
"tasks": {
+ "labels": {
+ "my_tasks_center": "Task Center",
+ "go_to_job": "Go to Job",
+ "overdue": "Overdue",
+ "due_today": "Today",
+ "upcoming": "Upcoming",
+ "no_due_date": "Incomplete",
+ "ro-number": "RO #{{ro_number}}",
+ "no_tasks": "No Tasks Found"
+ },
"actions": {
"edit": "Edit Task",
"new": "New Task",
@@ -3309,6 +3319,9 @@
"myTasks": "Mine",
"refresh": "Refresh"
},
+ "errors": {
+ "load_failure": "Failed to load Tasks."
+ },
"date_presets": {
"completion": "Completion",
"day": "Day",
diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json
index 15c9cabbc..ed7fb5ff9 100644
--- a/client/src/translations/es/common.json
+++ b/client/src/translations/es/common.json
@@ -3297,6 +3297,16 @@
}
},
"tasks": {
+ "labels": {
+ "my_tasks_center": "",
+ "go_to_job": "",
+ "overdue": "",
+ "due_today": "",
+ "upcoming": "",
+ "no_due_date": "",
+ "ro-number": "",
+ "no_tasks": ""
+ },
"actions": {
"edit": "",
"new": "",
@@ -3311,6 +3321,9 @@
"myTasks": "",
"refresh": ""
},
+ "errors": {
+ "load_failure": ""
+ },
"date_presets": {
"completion": "",
"day": "",
diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json
index 65c20f2da..2c0fae359 100644
--- a/client/src/translations/fr/common.json
+++ b/client/src/translations/fr/common.json
@@ -3297,6 +3297,16 @@
}
},
"tasks": {
+ "labels": {
+ "my_tasks_center": "",
+ "go_to_job": "",
+ "overdue": "",
+ "due_today": "",
+ "upcoming": "",
+ "no_due_date": "",
+ "ro-number": "",
+ "no_tasks": ""
+ },
"actions": {
"edit": "",
"new": "",
@@ -3311,6 +3321,9 @@
"myTasks": "",
"refresh": ""
},
+ "errors": {
+ "load_failure": ""
+ },
"date_presets": {
"completion": "",
"day": "",