mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
33 lines
802 B
TypeScript
33 lines
802 B
TypeScript
import { createContext, FC, useContext } from 'react';
|
|
|
|
import { observer } from 'mobx-react-lite';
|
|
|
|
import { useNotificationSettings } from '~/hooks/notifications/useNotificationSettings';
|
|
|
|
interface NotificationProviderProps {}
|
|
|
|
const defaultValue = {
|
|
available: false,
|
|
enabled: false,
|
|
hasNew: false,
|
|
indicatorEnabled: false,
|
|
markAsRead: () => {},
|
|
};
|
|
|
|
const NotificationContext = createContext(defaultValue);
|
|
|
|
const NotificationProvider: FC<NotificationProviderProps> = observer(
|
|
({ children }) => {
|
|
const value = useNotificationSettings();
|
|
|
|
return (
|
|
<NotificationContext.Provider value={value}>
|
|
{children}
|
|
</NotificationContext.Provider>
|
|
);
|
|
},
|
|
);
|
|
|
|
export const useNotifications = () => useContext(NotificationContext);
|
|
|
|
export { NotificationProvider };
|