2016-08-08 11:18:21 +09:00
|
|
|
import Telescope from 'meteor/nova:lib';
|
2016-04-14 10:12:35 +09:00
|
|
|
import React from 'react';
|
2016-11-10 15:39:04 +09:00
|
|
|
import { withPostsList } from 'meteor/nova:base-containers';
|
2016-04-14 10:12:35 +09:00
|
|
|
|
2016-11-10 15:39:04 +09:00
|
|
|
const PostsList = (props) => {
|
2016-04-14 10:12:35 +09:00
|
|
|
|
2016-11-10 15:39:04 +09:00
|
|
|
const {results, terms, hasMore, loading, count, totalCount, loadMore, showHeader = true} = props
|
|
|
|
|
|
|
|
if (results && results.length) {
|
2016-04-14 10:12:35 +09:00
|
|
|
return (
|
2016-04-19 15:45:36 +09:00
|
|
|
<div className="posts-list">
|
2016-10-25 15:48:54 +02:00
|
|
|
{showHeader ? <Telescope.components.PostsListHeader/> : null}
|
2016-04-19 15:45:36 +09:00
|
|
|
<div className="posts-list-content">
|
2016-11-08 12:58:53 +01:00
|
|
|
{results.map(post => <Telescope.components.PostsItem post={post} key={post._id} />)}
|
2016-04-14 10:12:35 +09:00
|
|
|
</div>
|
2016-05-22 16:42:24 +09:00
|
|
|
{hasMore ? (ready ? <Telescope.components.PostsLoadMore loadMore={loadMore} count={count} totalCount={totalCount} /> : <Telescope.components.PostsLoading/>) : <Telescope.components.PostsNoMore/>}
|
2016-04-14 10:12:35 +09:00
|
|
|
</div>
|
|
|
|
)
|
2016-11-10 15:39:04 +09:00
|
|
|
} else if (loading) {
|
|
|
|
return (
|
|
|
|
<div className="posts-list">
|
|
|
|
{showHeader ? <Telescope.components.PostsListHeader /> : null}
|
|
|
|
<div className="posts-list-content">
|
|
|
|
<Telescope.components.PostsLoading/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
2016-04-14 10:12:35 +09:00
|
|
|
} else {
|
|
|
|
return (
|
2016-04-19 15:45:36 +09:00
|
|
|
<div className="posts-list">
|
2016-05-22 16:42:24 +09:00
|
|
|
{showHeader ? <Telescope.components.PostsListHeader /> : null}
|
2016-04-19 15:45:36 +09:00
|
|
|
<div className="posts-list-content">
|
2016-05-22 16:42:24 +09:00
|
|
|
<Telescope.components.PostsNoResults/>
|
2016-04-14 10:12:35 +09:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2016-05-22 16:42:24 +09:00
|
|
|
PostsList.displayName = "PostsList";
|
|
|
|
|
2016-11-10 15:39:04 +09:00
|
|
|
PostsList.propTypes = {
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2016-11-10 17:27:06 +09:00
|
|
|
module.exports = withPostsList({})(PostsList); // get terms from parent component
|