// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 import React, { Dispatch, useContext, useReducer } from 'react'; import { Action, ActionType, initialState, NotificationType, reducer, Severity, StateType, } from './state'; const StateContext = React.createContext(initialState); const DispatchContext = React.createContext>((): void => {}); export const NotificationProvider: React.FC< React.PropsWithChildren > = ({ children }) => { const [state, dispatch] = useReducer(reducer, initialState); return ( {children} ); }; export const useNotificationState = () => { const state = useContext(StateContext); return state; }; export const useNotificationDispatch = () => { const dispatch = useContext(DispatchContext); return dispatch; }; export { Severity, NotificationType, ActionType, Action };