Files
fauxjira/client/src/Project/IssueDetails/Comments/index.jsx
2019-12-24 16:39:03 +01:00

29 lines
800 B
JavaScript

import React from 'react';
import PropTypes from 'prop-types';
import Create from './Create';
import Comment from './Comment';
import { Comments, Title } from './Styles';
const propTypes = {
issue: PropTypes.object.isRequired,
fetchIssue: PropTypes.func.isRequired,
};
const ProjectBoardIssueDetailsComments = ({ issue, fetchIssue }) => (
<Comments>
<Title>Comments</Title>
<Create issueId={issue.id} fetchIssue={fetchIssue} />
{sortByNewest(issue.comments).map(comment => (
<Comment key={comment.id} comment={comment} fetchIssue={fetchIssue} />
))}
</Comments>
);
const sortByNewest = items => items.sort((a, b) => -a.createdAt.localeCompare(b.createdAt));
ProjectBoardIssueDetailsComments.propTypes = propTypes;
export default ProjectBoardIssueDetailsComments;