Vulcan/packages/example-movies/lib/components/movies/MoviesList.jsx

64 lines
1.6 KiB
React
Raw Normal View History

/*
List of movies.
Wrapped with the "withList" and "withCurrentUser" containers.
*/
2017-05-19 14:42:43 -06:00
import React from 'react';
2017-03-23 16:27:59 +09:00
import { Components, withList, withCurrentUser, Loading } from 'meteor/vulcan:core';
2017-07-29 16:26:34 +09:00
import Helmet from 'react-helmet';
import Movies from '../../modules/movies/collection.js';
import MoviesItem from './MoviesItem.jsx';
import MoviesNewForm from './MoviesNewForm.jsx';
const MoviesList = ({results = [], currentUser, loading, loadMore, count, totalCount}) =>
2017-03-24 10:15:48 +09:00
<div style={{maxWidth: '500px', margin: '20px auto'}}>
2017-07-29 16:26:34 +09:00
<Helmet>
<link name="bootstrap" rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css"/>
</Helmet>
{/* user accounts */}
<div style={{padding: '20px 0', marginBottom: '20px', borderBottom: '1px solid #ccc'}}>
<Components.AccountsLoginForm />
</div>
{loading ?
<Loading /> :
<div className="movies">
{/* new document form */}
<MoviesNewForm />
{/* documents list */}
{results.map(movie => <MoviesItem key={movie._id} movie={movie} currentUser={currentUser} />)}
{/* load more */}
{totalCount > results.length ?
<a href="#" onClick={e => {e.preventDefault(); loadMore();}}>Load More ({count}/{totalCount})</a> :
<p>No more items.</p>
}
</div>
}
</div>
const options = {
collection: Movies,
fragmentName: 'MoviesItemFragment',
limit: 5
};
export default withList(options)(withCurrentUser(MoviesList));