import React from 'react'; import { Link } from 'react-router-dom'; import Icon from '../components/icon'; import { HorizontalRuleWithIcon } from '../components/globals'; const icons = { NEW_THREAD: 'post', NEW_MESSAGE: 'messages', default: 'notification', }; const colors = { NEW_THREAD: 'success.alt', NEW_MESSAGE: 'warn.alt', }; export const getIconByType = type => { return icons[type] || icons.default; }; export const getColorByType = type => { // TODO: add "readState" handling to change color to light gray return colors[type]; }; export const constructMessage = notification => { const { type, sender, community, channel, thread } = notification; switch (type) { case 'NEW_THREAD': return ( {sender.name} posted a new thread in{' '} {community.name}/{channel.name} : ); case 'NEW_MESSAGE': return ( {sender.name} replied to your{' '} thread : ); default: return; } }; export const constructLinklessMessage = notification => { const { type, sender, community, channel } = notification; switch (type) { case 'NEW_THREAD': return ( {sender.name} posted a new thread in{' '} {community.name}/{channel.name} ); case 'NEW_MESSAGE': return ( {sender.name} replied to your thread ); default: return; } }; export const constructContent = notification => { const { type, sender, content } = notification; switch (type) { case 'NEW_THREAD': return
{content.excerpt}
; case 'NEW_MESSAGE': return (