feature/IO-3096-GlobalNotifications - Checkpoint - Additional String Cleanup, loading spinner

This commit is contained in:
Dave Richer
2025-03-03 12:07:19 -05:00
parent 35b92570e5
commit 86aa5bf5e7
8 changed files with 46 additions and 20 deletions

View File

@@ -12,13 +12,14 @@ import {
MARK_NOTIFICATION_READ
} from "../../graphql/notifications.queries.js";
import { gql, useMutation } from "@apollo/client";
import { useTranslation } from "react-i18next";
const SocketContext = createContext(null);
const INITIAL_NOTIFICATIONS = 10;
/**
* Socket Provider - Scenario Notifications / Web Socket related items.
* Socket Provider - Scenario Notifications / Web Socket related items
* @param children
* @param bodyshop
* @param navigate
@@ -33,6 +34,7 @@ const SocketProvider = ({ children, bodyshop, navigate, currentUser, scenarioNot
const [isConnected, setIsConnected] = useState(false);
const notification = useNotification();
const userAssociationId = bodyshop?.associations?.[0]?.id;
const { t } = useTranslation();
const [markNotificationRead] = useMutation(MARK_NOTIFICATION_READ, {
update: (cache, { data: { update_notifications } }) => {
@@ -284,19 +286,18 @@ const SocketProvider = ({ children, bodyshop, navigate, currentUser, scenarioNot
});
notification.info({
message: `Changes for ${jobRoNumber}:`,
message: t("notifications.labels.notification-popup-title", { ro_number: jobRoNumber }),
description: (
<ul
className="notification-alert-unorderd-list"
className="notification-alert-unordered-list"
onClick={() => {
markNotificationRead({ variables: { id: notificationId } })
.then(() => navigate(`/manage/jobs/${jobId}`))
.catch((e) => console.error(`Error marking notification read: ${e?.message || ""}`));
}}
style={{ cursor: "pointer" }}
>
{notifications.map((notif, index) => (
<li className="notification-alert-unorderd-list-item" key={index}>
<li className="notification-alert-unordered-list-item" key={index}>
{notif.body}
</li>
))}