import React from 'react'; import { Button, NoContent } from 'UI'; import { connect } from 'react-redux'; import { fetchList, setViewed, clearAll } from 'Duck/notifications'; import { setLastRead } from 'Duck/announcements'; import cn from 'classnames'; import AnimatedSVG, { ICONS } from 'Shared/AnimatedSVG/AnimatedSVG'; import ListItem from './ListItem' interface Props { unReadNotificationsCount: number; setLastRead: Function; clearingAll: boolean; loading: boolean; clearing: boolean; list: any; clearAll: Function; setViewed: Function; } function AlertTriggersModal(props: Props) { const { list, unReadNotificationsCount, loading, clearingAll, clearing } = props; const onClearAll = () => { const { list } = props; const firstItem = list.first(); props.clearAll({ endTimestamp: firstItem.createdAt.ts }); } const onClear = (notification: any) => { console.log('onClear', notification); props.setViewed(notification.notificationId) } return (
Alerts
{ unReadNotificationsCount > 0 && (
)}
} subtext="There are no alerts to show." show={ !loading && unReadNotificationsCount === 0 } size="small" > {list.map((item: any, i: any) => (
onClear(item)} loading={false} />
))}
); } export default connect((state: any) => ({ loading: state.getIn(['notifications', 'fetchRequest', 'loading']), clearing: state.getIn(['notifications', 'setViewed', 'loading']), clearingAll: state.getIn(['notifications', 'clearAll', 'loading']), list: state.getIn(['notifications', 'list']), }), { fetchList, setLastRead, setViewed, clearAll, })(AlertTriggersModal);