Created
January 4, 2016 03:16
-
-
Save rfischer20/cea41504ae04ce1e6032 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
const SUBMIT_BUG = 'bugshift/SUBMIT_BUG'; | |
const initialState = []; | |
export default function reducer(state = initialState, action = {}) { | |
const { type, payload } = action; | |
switch (type) { | |
case SUBMIT_BUG: | |
return [{ | |
bugState: 'draft' | |
}, ...state]; | |
default: | |
return state; | |
} | |
} | |
export function createBug(bug){ | |
return { | |
type: SUBMIT_BUG, | |
payload: { | |
bugState: 'pending' | |
} | |
}; | |
} |
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, { Component, PropTypes } from 'react'; | |
import { connect } from 'react-redux'; | |
import { bindActionCreators } from 'redux'; | |
import * as BugActions from '../redux/modules/bugform'; | |
import { initialize } from 'redux-form'; | |
import BugForm from '../components/BugForm'; | |
class BugFormView extends Component { | |
handleSubmit(data){ | |
console.warn(this); | |
console.warn(this.props); | |
this.props.dispatch(BugActions.createBug(data)); | |
} | |
render() { | |
const { dispatch } = this.props; | |
console.warn('showing props'); | |
console.warn(this.props); | |
//console.warn(bugState); | |
console.warn(BugActions); | |
console.warn(dispatch); | |
//const actions = bindActionCreators(BugActions, dispatch); | |
return ( | |
<div> | |
<BugForm onSubmit={this.handleSubmit.bind(this)}/> | |
{'test'} | |
</div> | |
) | |
} | |
} | |
function mapStateToProps(state) { | |
return { bugState: state.bugState } | |
} | |
export default connect(mapStateToProps)(BugFormView) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment