import React from 'react'; import PropTypes from 'prop-types'; import { ButtonToolbar, ButtonGroup, Button } from 'react-bootstrap'; import { createContainer } from 'meteor/react-meteor-data'; import { Meteor } from 'meteor/meteor'; import { Bert } from 'meteor/themeteorchef:bert'; import Documents from '../../../api/Documents/Documents'; import NotFound from '../NotFound/NotFound'; const handleRemove = (documentId, history) => { if (confirm('Are you sure? This is permanent!')) { Meteor.call('documents.remove', documentId, (error) => { if (error) { Bert.alert(error.reason, 'danger'); } else { Bert.alert('Document deleted!', 'success'); history.push('/documents'); } }); } }; const ViewDocument = ({ doc, match, history }) => (doc ? (

{ doc && doc.title }

{ doc && doc.body }
) : ); ViewDocument.propTypes = { doc: PropTypes.object.isRequired, match: PropTypes.object.isRequired, history: PropTypes.object.isRequired, }; export default createContainer(({ match }) => { const documentId = match.params._id; const subscription = Meteor.subscribe('documents.view', documentId); return { loading: !subscription.ready(), doc: Documents.findOne(documentId), }; }, ViewDocument);