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 ReactDOM from 'react-dom'; | |
import { Provider } from 'react-redux'; | |
import { reduxReactRouter, ReduxRouter } from 'redux-router'; | |
import Routes from './routes'; | |
import { configureStore } from './Store'; | |
import createHistory from 'history/lib/createBrowserHistory' | |
var app = document.getElementById('app'); |
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 { connect } from 'react-redux'; | |
import Rate from './Rate'; | |
import Submission from './Submission'; | |
import { performRating, fetchSubmission } from '../actions_creators/SubmissionActionsCreator'; | |
class SubmissionPage extends React.Component { | |
static fetchData(dispatch, params) { | |
return dispatch(fetchSubmission(params.id)); | |
} |
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 ActionTypes from '../constants/ActionTypes'; | |
import Connection from '../lib/Connection'; | |
const _requestPerformRating = (id) => { | |
return { | |
type: ActionTypes.PERFORM_RATING, | |
id: id | |
} | |
} |
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
export default { | |
PERFORM_RATING: 'PERFORM_RATING', | |
RATING_PERFORMED: 'RATING_PERFORMED', | |
REQUEST_SUBMISSIONS_LIST: 'REQUEST_SUBMISSIONS_LIST', | |
RECEIVE_SUBMISSIONS_LIST: 'RECEIVE_SUBMISSIONS_LIST', | |
REQUEST_SUBMISSION: 'REQUEST_SUBMISSION', | |
RECEIVE_SUBMISSION: 'RECEIVE_SUBMISSION' | |
}; |
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 ActionTypes from '../constants/ActionTypes'; | |
let SubmissionReducer = (state = {}, action) => { | |
switch (action.type) { | |
case ActionTypes.RECEIVE_SUBMISSION: | |
case ActionTypes.RATING_PERFORMED: | |
return action.submission; | |
default: | |
return state; | |
} |
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 ActionTypes from '../constants/ActionTypes'; | |
import SubmissionReducer from './SubmissionReducer' | |
let SubmissionsListReducer = (state = {}, action) => { | |
let newState; | |
switch (action.type) { | |
case ActionTypes.RECEIVE_SUBMISSIONS_LIST: | |
newState = {}; | |
action.submissions.forEach((s) => { |
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 { createStore, combineReducers, applyMiddleware, compose } from 'redux'; | |
import { routerStateReducer } from 'redux-router'; | |
import thunk from 'redux-thunk'; | |
import SubmissionsListReducer from './reducers/SubmissionsListReducer'; | |
import routes from './routes'; | |
const reducers = combineReducers({ | |
submissions: SubmissionsListReducer, | |
router: routerStateReducer | |
}); |
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); |
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 { EventEmitter } from 'events'; | |
import {ReduceStore} from 'flux/utils'; | |
import AppDispatcher from '../AppDispatcher'; | |
import ActionTypes from '../constants/ActionTypes'; | |
import Connection from '../lib/Connection'; | |
const CHANGE_EVENT = 'change'; | |
class SubmissionStore extends EventEmitter { | |
constructor() { |
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 SubmissionActionsCreator from '../actions/SubmissionActionsCreator'; | |
class SubmissionPage extends React.Component { | |
// ... | |
performRating(value) { | |
const id = this.state.submission.id; | |
SubmissionActionsCreator.performRating(id, value); | |
} |