mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-04 00:53:14 +00:00
19 lines
587 B
TypeScript
19 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;
|
||
|
|
}
|