Files
frontend-app-discussions/src/discussions/comments/comment-icons/CommentIcons.jsx
Kshitij Sobti c8c3bb925c feat: Improve UX to match new mockups
Uses new API features for preview, deleting, pinning, and closing. Refactors and improves styling to match new mockups.
Adds the new post filter bar element.
2021-10-28 16:43:28 +05:30

44 lines
1.1 KiB
JavaScript

import React from 'react';
import PropTypes from 'prop-types';
import { useDispatch } from 'react-redux';
import * as timeago from 'timeago.js';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import LikeButton from '../../posts/post/LikeButton';
import { editComment } from '../data/thunks';
function CommentIcons({
comment,
intl,
}) {
const dispatch = useDispatch();
const handleLike = () => dispatch(editComment(comment.id, { voted: !comment.voted }));
return (
<div className="d-flex flex-row align-items-center">
<LikeButton
count={comment.voteCount}
onClick={handleLike}
voted={comment.voted}
/>
<div className="d-flex flex-fill text-gray-500 justify-content-end mt-2" title={comment.createdAt}>
{timeago.format(comment.createdAt, intl.locale)}
</div>
</div>
);
}
CommentIcons.propTypes = {
comment: PropTypes.shape({
id: PropTypes.string,
voteCount: PropTypes.number,
following: PropTypes.bool,
voted: PropTypes.bool,
createdAt: PropTypes.string,
}).isRequired,
intl: intlShape.isRequired,
};
export default injectIntl(CommentIcons);