2016-11-22 16:46:32 +09:00
|
|
|
/*
|
|
|
|
|
|
|
|
A component that shows a detailed view of a single movie.
|
2016-12-12 09:54:16 +09:00
|
|
|
Wrapped with the "withDocument" container.
|
2016-11-22 16:46:32 +09:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
2016-11-22 16:15:00 +09:00
|
|
|
import React, { PropTypes, Component } from 'react';
|
|
|
|
import Movies from '../collection.js';
|
2017-01-18 12:51:10 +01:00
|
|
|
import { withDocument, registerComponent } from 'meteor/nova:core';
|
2016-11-24 16:58:08 +09:00
|
|
|
import gql from 'graphql-tag';
|
2016-11-22 16:15:00 +09:00
|
|
|
|
|
|
|
const MoviesDetails = props => {
|
|
|
|
const movie = props.document;
|
|
|
|
if (props.loading) {
|
|
|
|
return <p>Loading…</p>
|
|
|
|
} else {
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<h2>{movie.name} ({movie.year})</h2>
|
2017-01-18 10:18:33 +09:00
|
|
|
<p>Reviewed by <strong>{movie.user && movie.user.displayName}</strong> on {movie.createdAt}</p>
|
2016-11-22 16:15:00 +09:00
|
|
|
<p>{movie.review}</p>
|
2016-12-01 15:29:07 +09:00
|
|
|
{movie.privateComments ? <p><strong>PRIVATE</strong>: {movie.privateComments}</p>: null}
|
2016-11-22 16:15:00 +09:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-24 16:58:08 +09:00
|
|
|
MoviesDetails.fragment = gql`
|
|
|
|
fragment moviesDetailsFragment on Movie {
|
|
|
|
_id
|
|
|
|
name
|
|
|
|
createdAt
|
|
|
|
year
|
|
|
|
review
|
|
|
|
privateComments
|
|
|
|
user {
|
2017-01-18 10:18:33 +09:00
|
|
|
displayName
|
2016-11-24 16:58:08 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2016-11-22 16:15:00 +09:00
|
|
|
const options = {
|
|
|
|
collection: Movies,
|
|
|
|
queryName: 'moviesSingleQuery',
|
2016-11-24 16:58:08 +09:00
|
|
|
fragment: MoviesDetails.fragment,
|
2016-11-22 16:15:00 +09:00
|
|
|
};
|
|
|
|
|
2017-01-18 12:51:10 +01:00
|
|
|
registerComponent('MoviesDetails', MoviesDetails, withDocument(options));
|