import React from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import { useTranslation, Trans } from 'react-i18next'; import { Comment } from 'semantic-ui-react'; import { ActionTypes } from '../../../constants/Enums'; import ItemComment from './ItemComment'; import User from '../../User'; import styles from './Item.module.css'; const Item = React.memo(({ type, data, createdAt, user }) => { const [t] = useTranslation(); let contentNode; switch (type) { case ActionTypes.CREATE_CARD: contentNode = ( {user.name} {' added this card to '} {data.list.name} ); break; case ActionTypes.MOVE_CARD: contentNode = ( {user.name} {' moved this card from '} {data.fromList.name} {' to '} {data.toList.name} ); break; default: contentNode = null; } return (
{contentNode}
{t('format:longDateTime', { postProcess: 'formatDate', value: createdAt, })}
); }); Item.Comment = ItemComment; Item.propTypes = { type: PropTypes.string.isRequired, data: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types createdAt: PropTypes.instanceOf(Date).isRequired, user: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types }; export default Item;