Last active
November 3, 2015 18:44
-
-
Save lesniakania/26086f0c57797269b273 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import Rate from './Rate'; | |
import SubmissionStore from '../stores/SubmissionStore'; | |
import SubmissionActionsCreator from '../actions/SubmissionActionsCreator'; | |
class SubmissionPage extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { submission: {} }; | |
this._onChange = this.onChange.bind(this); | |
} | |
componentDidMount() { | |
const id = this.props.params.id; | |
SubmissionActionsCreator.requestSubmission(id); | |
} | |
componentWillMount() { | |
SubmissionStore.addChangeListener(this._onChange); | |
} | |
componentWillUnmount() { | |
SubmissionStore.removeChangeListener(this._onChange); | |
} | |
onChange() { | |
this.setState({ submission: SubmissionStore.getSubmission() }); | |
} | |
performRating(value) { | |
const id = this.state.submission.id; | |
SubmissionActionsCreator.performRating(id, value); | |
} | |
render() { | |
const submission = this.state.submission; | |
return ( | |
<div> | |
<div className="submission"> | |
<h2>Submission</h2> | |
<ul> | |
<li>Id: {submission.id}</li> | |
<li>First Name: {submission.first_name}</li> | |
<li>Last Name: {submission.last_name}</li> | |
</ul> | |
</div> | |
<Rate rate={submission.rate} performRating={this.performRating.bind(this)} /> | |
</div> | |
) | |
} | |
}; | |
export default SubmissionPage; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment