wip wiring up account forms
This commit is contained in:
parent
cdc15f019d
commit
3459bf26f8
25 changed files with 413 additions and 53 deletions
|
|
@ -0,0 +1,54 @@
|
|||
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 ? (
|
||||
<div className="ViewDocument">
|
||||
<div className="page-header clearfix">
|
||||
<h4 className="pull-left">{ doc && doc.title }</h4>
|
||||
<ButtonToolbar className="pull-right">
|
||||
<ButtonGroup bsSize="small">
|
||||
<Button onClick={() => history.push(`${match.url}/edit`)}>Edit</Button>
|
||||
<Button onClick={() => handleRemove(doc._id, history)} className="text-danger">
|
||||
Delete
|
||||
</Button>
|
||||
</ButtonGroup>
|
||||
</ButtonToolbar>
|
||||
</div>
|
||||
{ doc && doc.body }
|
||||
</div>
|
||||
) : <NotFound />);
|
||||
|
||||
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);
|
||||
Loading…
Add table
Add a link
Reference in a new issue