Vulcan/packages/nova-components/lib/comments/list/CommentEdit.jsx

45 lines
1 KiB
React
Raw Normal View History

2016-02-18 21:39:33 +09:00
import Formsy from 'formsy-react';
import FRC from 'formsy-react-components';
const Textarea = FRC.Textarea;
const CommentEdit = React.createClass({
propTypes: {
comment: React.PropTypes.object.isRequired,
2016-02-19 10:12:08 +09:00
submitCallback: React.PropTypes.func,
cancelCallback: React.PropTypes.func
2016-02-18 21:39:33 +09:00
},
submitComment(data) {
data = {$set: data};
Meteor.call("comments.edit", data, this.props.comment._id, (error, result) => {
if (error) {
// handle error
} else {
this.props.submitCallback();
}
});
},
render() {
return (
<Formsy.Form onSubmit={this.submitComment}>
<Textarea
name="body"
value={this.props.comment.body}
label="Body"
type="text"
2016-02-19 09:54:13 +09:00
className="textarea"
2016-02-18 21:39:33 +09:00
/>
2016-02-19 09:54:13 +09:00
<button type="submit" className="button button--primary">Submit</button>
2016-02-19 10:12:08 +09:00
<a href="#" onClick={this.props.cancelCallback} className="button button--secondary">Cancel</a>
2016-02-18 21:39:33 +09:00
</Formsy.Form>
)
}
});
module.exports = CommentEdit;