import React from 'react'; import moment from 'moment'; import { toast } from 'react-hot-toast'; import { commentNotificationsService } from '@/_services'; import { hightlightMentionedUserInComment } from '@/_helpers/utils'; export const Notification = ({ id, creator, comment, updatedAt, commentLink, isRead, fetchData, darkMode }) => { const updateMentionedNotification = async () => { const { error } = await commentNotificationsService.update(id, !isRead); if (error) { toast.error('Unable to update notification'); return; } fetchData(); }; const updated = moment(updatedAt).fromNow(); return (
{creator?.avatar ? ( ) : ( {creator.firstName.charAt(0)} {creator?.lastName?.charAt(0)} )}
{creator.firstName} mentioned you
{updated === 'just now' ? updated : `${updated} ago`}
); };