mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-09-30 06:53:12 +00:00
Header bell panel and /notifications page share one feed from GET /api/notifications: labeled sections with live counts, unread styling, session-only dismiss and clear all (acknowledge rows excluded), and deep links to the unassigned queue and a work order's tab via ?wo=&tab=.
18 lines
587 B
TypeScript
18 lines
587 B
TypeScript
import { createContext, useContext } from "react";
|
|
|
|
export type NotificationSession = {
|
|
dismissedIds: ReadonlySet<string>;
|
|
readIds: ReadonlySet<string>;
|
|
dismiss: (ids: string[]) => void;
|
|
markRead: (ids: string[]) => void;
|
|
};
|
|
|
|
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;
|
|
}
|