Devendra174's picture
Upload folder using huggingface_hub
1e92f2d verified
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 (
<span>
<Link to={`/@${sender.username}`}>{sender.name}</Link> posted a new
thread in{' '}
<Link to={`/${community.slug}/${channel.slug}`}>
{community.name}/{channel.name}
</Link>
:
</span>
);
case 'NEW_MESSAGE':
return (
<span>
<Link to={`/@${sender.username}`}>{sender.name}</Link> replied to your{' '}
<Link
to={{
pathname: getThreadLink(thread),
state: { modal: true },
}}
>
thread
</Link>
:
</span>
);
default:
return;
}
};
export const constructLinklessMessage = notification => {
const { type, sender, community, channel } = notification;
switch (type) {
case 'NEW_THREAD':
return (
<span>
<b>{sender.name}</b> posted a new thread in{' '}
<b>
{community.name}/{channel.name}
</b>
</span>
);
case 'NEW_MESSAGE':
return (
<span>
<b>{sender.name}</b> replied to your <b>thread</b>
</span>
);
default:
return;
}
};
export const constructContent = notification => {
const { type, sender, content } = notification;
switch (type) {
case 'NEW_THREAD':
return <p>{content.excerpt}</p>;
case 'NEW_MESSAGE':
return (
<div>
<HorizontalRuleWithIcon>
<hr />
<Icon glyph={'messages'} />
<hr />
</HorizontalRuleWithIcon>
</div>
);
default:
return;
}
};