import { Fragment, useEffect } from 'react' import { notification, message } from 'antd' import IonIcon from '@sentre/antd-ionicon' import { useRootDispatch, RootDispatch } from 'store' import { resize } from 'store/ui.reducer' const UIWatcher = () => { const [notificationAPI, notificationContextHolder] = notification.useNotification() const [mesageAPI, mesageContextHolder] = message.useMessage() const dispatch = useRootDispatch() // Notification system window.notify = ({ type, description, onClick = () => {}, }: SentreNotification) => { return notificationAPI[type]({ message: type.toUpperCase(), description, onClick, style: { cursor: 'pointer' }, closeIcon: , }) } // Message system window.message = ({ type, description }: SentreMessage) => { return mesageAPI[type](description) } // Listen window events useEffect(() => { window.addEventListener('resize', () => dispatch(resize())) return () => window.removeEventListener('resize', () => dispatch(resize())) }, [dispatch]) return ( {notificationContextHolder} {mesageContextHolder} ) } export default UIWatcher