mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-09-30 06:53:12 +00:00
Dispatchers see a one-line banner and a one-time toast while a Reactive/Emergency work order is past half of its SEV response window; the banner opens the board on exactly those work orders and dismisses for the session. Missed deadlines stay in the notification center until acknowledged, and Clear all skips them.
23 lines
921 B
TypeScript
23 lines
921 B
TypeScript
import { createContext, useContext } from "react";
|
|
|
|
export type NotificationSession = {
|
|
dismissedIds: ReadonlySet<string>;
|
|
readIds: ReadonlySet<string>;
|
|
dismiss: (ids: string[]) => void;
|
|
markRead: (ids: string[]) => void;
|
|
/** At-risk work orders hidden from the SLA banner for this session. */
|
|
slaBannerDismissedIds: ReadonlySet<number>;
|
|
dismissSlaBanner: (workOrderIds: number[]) => void;
|
|
/** Returns the ids not toasted yet this session and marks them toasted, so each toast fires once. */
|
|
claimSlaToasts: (workOrderIds: number[]) => number[];
|
|
};
|
|
|
|
export const NotificationSessionContext = createContext<NotificationSession | null>(null);
|
|
|
|
export function useNotificationSession(): NotificationSession {
|
|
const session = useContext(NotificationSessionContext);
|
|
if (!session) {
|
|
throw new Error("useNotificationSession must be used within a NotificationSessionProvider");
|
|
}
|
|
return session;
|
|
}
|