mirror of
https://github.com/vale981/Vulcan
synced 2025-03-09 20:16:39 -04:00
63 lines
1.5 KiB
React
63 lines
1.5 KiB
React
![]() |
/*
|
||
|
|
||
|
List of movies.
|
||
|
Wrapped with the "withList" and "withCurrentUser" containers.
|
||
|
|
||
|
*/
|
||
|
|
||
|
import React from 'react';
|
||
|
import { Components, withList, withCurrentUser, Loading } from 'meteor/vulcan:core';
|
||
|
|
||
|
import Movies from '../../modules/movies/collection.js';
|
||
|
|
||
|
const MoviesList = ({results = [], currentUser, loading, loadMore, count, totalCount}) =>
|
||
|
|
||
|
<div style={{maxWidth: '500px', margin: '20px auto'}}>
|
||
|
|
||
|
{/* user accounts */}
|
||
|
|
||
|
<div style={{padding: '20px 0', marginBottom: '20px', borderBottom: '1px solid #ccc'}}>
|
||
|
|
||
|
<Components.AccountsLoginForm />
|
||
|
|
||
|
</div>
|
||
|
|
||
|
{loading ?
|
||
|
|
||
|
<Loading /> :
|
||
|
|
||
|
<div className="movies">
|
||
|
|
||
|
{/* new document form */}
|
||
|
|
||
|
{Movies.options.mutations.new.check(currentUser) ?
|
||
|
<div style={{marginBottom: '20px', paddingBottom: '20px', borderBottom: '1px solid #ccc'}}>
|
||
|
<h4>Insert New Document</h4>
|
||
|
<Components.SmartForm collection={Movies} />
|
||
|
</div> :
|
||
|
null
|
||
|
}
|
||
|
|
||
|
{/* documents list */}
|
||
|
|
||
|
{results.map(movie => <Components.Card key={movie._id} collection={Movies} document={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,
|
||
|
limit: 5,
|
||
|
pollInterval: 0
|
||
|
};
|
||
|
|
||
|
export default withList(options)(withCurrentUser(MoviesList));
|