import React, { useEffect } from 'react'; import { NoContent, Loader } from 'UI'; import { Button } from 'antd'; import cn from 'classnames'; import AnimatedSVG, { ICONS } from 'Shared/AnimatedSVG/AnimatedSVG'; import { useStore } from 'App/mstore'; import { useObserver } from 'mobx-react-lite'; import ListItem from './ListItem'; import { useTranslation } from 'react-i18next'; interface Props {} function AlertTriggersModal(props: Props) { const { t } = useTranslation(); const { notificationStore } = useStore(); const count = useObserver(() => notificationStore.notificationsCount); const list = useObserver(() => notificationStore.notifications); const loading = useObserver(() => notificationStore.loading); const markingAsRead = useObserver(() => notificationStore.markingAsRead); const onClearAll = () => { const firstItem = list[0]; if (!firstItem) return; notificationStore.ignoreAllNotifications({ endTimestamp: firstItem.createdAt.ts, }); }; const onClear = (notification: any) => { notificationStore.ignoreNotification(notification.notificationId); }; useEffect(() => { notificationStore.fetchNotifications(); }, []); return useObserver(() => (
{t('Alerts')}
{count > 0 && (
)}
} subtext="There are no alerts to show" show={!loading && list.length === 0} size="small" > {list.map((item: any, i: any) => (
onClear(item)} loading={markingAsRead} />
))}
)); } export default AlertTriggersModal;