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

49 lines
1.2 KiB
React
Raw Normal View History

2016-03-17 17:48:25 +09:00
import React, { PropTypes, Component } from 'react';
2016-02-18 21:39:33 +09:00
import Formsy from 'formsy-react';
import FRC from 'formsy-react-components';
const Textarea = FRC.Textarea;
2016-03-17 17:48:25 +09:00
class CommentEdit extends Component {
2016-02-18 21:39:33 +09:00
2016-03-17 17:48:25 +09:00
constructor() {
super();
this.submitComment = this.submitComment.bind(this);
}
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();
}
});
2016-03-17 17:48:25 +09:00
}
2016-02-18 21:39:33 +09:00
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>
)
}
2016-03-17 17:48:25 +09:00
}
CommentEdit.propTypes = {
comment: React.PropTypes.object.isRequired,
submitCallback: React.PropTypes.func,
cancelCallback: React.PropTypes.func
}
2016-02-18 21:39:33 +09:00
module.exports = CommentEdit;