Vulcan/packages/nova-base-components/lib/comments/CommentsList.jsx

33 lines
964 B
React
Raw Normal View History

2016-04-14 10:12:35 +09:00
import React from 'react';
2016-06-09 17:42:20 +09:00
import {injectIntl, FormattedMessage} from 'react-intl';
2016-04-14 10:12:35 +09:00
const CommentsList = ({results, currentUser, hasMore, ready, count, totalCount, loadMore}) => {
if (!!results.length) {
return (
<div className="comments-list">
{results.map(comment => <Telescope.components.CommentsNode comment={comment} key={comment._id} currentUser={currentUser}/>)}
{hasMore ? (ready ? <Telescope.components.CommentsLoadMore loadMore={loadMore} count={count} totalCount={totalCount} /> : <Telescope.components.Loading/>) : null}
2016-04-14 10:12:35 +09:00
</div>
)
} else if (!ready) {
return (
<div className="comments-list">
<Telescope.components.Loading/>
2016-04-14 10:12:35 +09:00
</div>
)
} else {
return (
<div className="comments-list">
2016-06-09 17:42:20 +09:00
<p>
<FormattedMessage id="comments.no_comments"/>
</p>
2016-04-14 10:12:35 +09:00
</div>
)
}
};
CommentsList.displayName = "CommentsList";
2016-04-14 10:12:35 +09:00
module.exports = CommentsList;