import React, { useEffect } from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; import { useDispatch, useSelector } from 'react-redux'; import { useHistory } from 'react-router-dom'; import { formatDate } from '../../helpers/utils/util'; import { getNotifications, getSnapsRouteObjects, getUnreadNotifications, } from '../../selectors'; import { DEFAULT_ROUTE } from '../../helpers/constants/routes'; import { deleteExpiredNotifications, markNotificationsAsRead, } from '../../store/actions'; import Button from '../../components/ui/button'; import { useI18nContext } from '../../hooks/useI18nContext'; import { ButtonIcon, ICON_SIZES, ICON_NAMES, } from '../../components/component-library'; import { Color } from '../../helpers/constants/design-system'; export function NotificationItem({ notification, snaps, onItemClick }) { const { message, origin, createdDate, readDate } = notification; const history = useHistory(); const t = useI18nContext(); const snap = snaps.find(({ id: snapId }) => { return snapId === origin; }); const handleNameClick = (e) => { e.stopPropagation(); history.push(snap.route); }; const handleItemClick = () => onItemClick(notification); return (
{message}
{t('notificationsInfos', [ formatDate(createdDate, "LLLL d',' yyyy 'at' t"), , ])}