diff options
Diffstat (limited to 'web/src/hooks/NotificationsContext.ts')
| -rw-r--r-- | web/src/hooks/NotificationsContext.ts | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/web/src/hooks/NotificationsContext.ts b/web/src/hooks/NotificationsContext.ts index 48ff7b0a5..0cacc3c53 100644 --- a/web/src/hooks/NotificationsContext.ts +++ b/web/src/hooks/NotificationsContext.ts @@ -1,33 +1,33 @@ -import { Level } from "../components/ColoredSnackbarContent"; import { useCallback, createContext, useContext } from "react"; + +import { Level } from "../components/ColoredSnackbarContent"; import { Notification } from "../models/Notifications"; const defaultOptions = { timeout: 5, -} +}; interface NotificationContextProps { notification: Notification | null; setNotification: (n: Notification | null) => void; } -const NotificationsContext = createContext<NotificationContextProps>( - { notification: null, setNotification: () => { } }); +const NotificationsContext = createContext<NotificationContextProps>({ notification: null, setNotification: () => {} }); export default NotificationsContext; - export function useNotifications() { let useNotificationsProps = useContext(NotificationsContext); const notificationBuilder = (level: Level) => { return (message: string, timeout?: number) => { useNotificationsProps.setNotification({ - level, message, - timeout: timeout ? timeout : defaultOptions.timeout + level, + message, + timeout: timeout ? timeout : defaultOptions.timeout, }); - } - } + }; + }; const resetNotification = () => useNotificationsProps.setNotification(null); /* eslint-disable react-hooks/exhaustive-deps */ @@ -38,7 +38,6 @@ export function useNotifications() { /* eslint-enable react-hooks/exhaustive-deps */ const isActive = useNotificationsProps.notification !== null; - return { notification: useNotificationsProps.notification, resetNotification, @@ -46,6 +45,6 @@ export function useNotifications() { createSuccessNotification, createWarnNotification, createErrorNotification, - isActive - } -}
\ No newline at end of file + isActive, + }; +} |
