diff --git a/client/src/components/header/header.component.jsx b/client/src/components/header/header.component.jsx
index df09cd05b..3dccc1842 100644
--- a/client/src/components/header/header.component.jsx
+++ b/client/src/components/header/header.component.jsx
@@ -128,7 +128,6 @@ function Header({
const { isConnected } = useSocket(bodyshop);
const [notificationVisible, setNotificationVisible] = useState(false);
- const [displayCount, setDisplayCount] = useState(0); // Explicit state for badge
const {
data: unreadData,
@@ -141,37 +140,17 @@ function Header({
const unreadCount = unreadData?.notifications_aggregate?.aggregate?.count ?? 0;
- // Update displayCount when unreadCount changes
- useEffect(() => {
- console.log("Updating displayCount with unreadCount:", unreadCount);
- setDisplayCount(unreadCount);
- }, [unreadCount]);
-
// Initial fetch and socket status handling
useEffect(() => {
- console.log("Running initial refetchUnread");
refetchUnread();
}, [refetchUnread]);
useEffect(() => {
if (!isConnected && !unreadLoading) {
- console.log("Socket disconnected, refetching unread count");
refetchUnread();
}
}, [isConnected, unreadLoading, refetchUnread]);
- // Debug logging
- useEffect(() => {
- console.log("Unread Count State:", {
- unreadCount,
- displayCount,
- unreadLoading,
- isConnected,
- unreadData: unreadData?.notifications_aggregate,
- rawUnreadData: unreadData
- });
- }, [unreadCount, displayCount, unreadLoading, isConnected, unreadData]);
-
const handleNotificationClick = (e) => {
setNotificationVisible(!notificationVisible);
if (handleMenuClick) handleMenuClick(e);
@@ -710,7 +689,7 @@ function Header({
icon: unreadLoading ? (
) : (
-
+
),
diff --git a/client/src/contexts/SocketIO/socketContext.jsx b/client/src/contexts/SocketIO/socketContext.jsx
index 7e01490dd..cd9ec950c 100644
--- a/client/src/contexts/SocketIO/socketContext.jsx
+++ b/client/src/contexts/SocketIO/socketContext.jsx
@@ -87,6 +87,8 @@ export const SocketProvider = ({ children, bodyshop }) => {
const handleNotification = (data) => {
const { jobId, jobRoNumber, notificationId, associationId, notifications } = data;
+ console.log(`Got RO ${jobRoNumber}`);
+
const newNotification = {
__typename: "notifications",
id: notificationId,
@@ -96,8 +98,7 @@ export const SocketProvider = ({ children, bodyshop }) => {
fcm_text: notifications.map((notif) => notif.body).join(". ") + ".",
scenario_meta: JSON.stringify(notifications.map((notif) => notif.variables || {})),
created_at: new Date(notifications[0].timestamp).toISOString(),
- read: null,
- job: { ro_number: jobRoNumber }
+ read: null
};
try {
@@ -115,9 +116,6 @@ export const SocketProvider = ({ children, bodyshop }) => {
scenario_meta
created_at
read
- job {
- ro_number
- }
}
}
`
@@ -140,9 +138,6 @@ export const SocketProvider = ({ children, bodyshop }) => {
scenario_meta
created_at
read
- job {
- ro_number
- }
}
}
`,