import { Components, registerComponent, withList, withCurrentUser, Utils } from 'meteor/vulcan:core'; import React from 'react'; import PropTypes from 'prop-types'; import Posts from 'meteor/vulcan:posts'; import Alert from 'react-bootstrap/lib/Alert' import { FormattedMessage, intlShape } from 'meteor/vulcan:i18n'; import classNames from 'classnames'; const Error = ({error}) => {error.message} const PostsList = ({className, results, loading, count, totalCount, loadMore, showHeader = true, showLoadMore = true, networkStatus, currentUser, error, terms}) => { const loadingMore = networkStatus === 2; if (results && results.length) { const hasMore = totalCount > results.length; return (
{showHeader ? : null} {error ? : null }
{results.map(post => )}
{showLoadMore ? hasMore ? : : null }
) } else if (loading) { return (
{showHeader ? : null} {error ? : null }
) } else { return (
{showHeader ? : null} {error ? : null }
) } }; PostsList.displayName = "PostsList"; PostsList.propTypes = { results: PropTypes.array, terms: PropTypes.object, hasMore: PropTypes.bool, loading: PropTypes.bool, count: PropTypes.number, totalCount: PropTypes.number, loadMore: PropTypes.func, showHeader: PropTypes.bool, }; PostsList.contextTypes = { intl: intlShape }; const options = { collection: Posts, queryName: 'postsListQuery', fragmentName: 'PostsList', }; registerComponent('PostsList', PostsList, withCurrentUser, [withList, options]);