Skip to content

Commit

Permalink
Add issues store and submit handler
Browse files Browse the repository at this point in the history
  • Loading branch information
hedgepigdaniel committed Oct 13, 2017
1 parent 33166c0 commit 5a06930
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 11 deletions.
4 changes: 4 additions & 0 deletions src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ export const visitVideo = slug => ({
type: 'VIDEO',
payload: { slug },
})

export const commitIssue = () => ({
type: 'COMMIT_ISSUE',
})
39 changes: 29 additions & 10 deletions src/components/Admin.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@
import React from 'react'
import React, { PureComponent } from 'react'
import { connect } from 'react-redux'

import { commitIssue } from '../actions'

import { admin } from '../css/Switcher'

import DateTimePicker from './DateTimePicker'
import MeetingTable from './MeetingTable'

const MeetingAgenda = () =>
<div>
<label htmlFor='MettingDate'> Meeting Date </label>
<DateTimePicker />
<div>
<MeetingTable />
<button>Add another </button>
</div>
</div>
class _MeetingAgenda extends PureComponent {
onSubmit = () => {}

render() {
return (
<div>
<label htmlFor='MettingDate'> Meeting Date </label>
<DateTimePicker />
<div>
<MeetingTable />
<button onClick={this.onSubmit}>Submit</button>
</div>
</div>
)
}
}

const MeetingAgenda = connect(
() => ({}),
dispatch =>
({
onSubmit: () => dispatch(commitIssue()),
}(_MeetingAgenda))
)

export default MeetingAgenda
17 changes: 16 additions & 1 deletion src/reducers/issues.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,24 @@ import { fromJS } from 'immutable'
const updaters = new Map([
['@@redux/INIT', state => fromJS(state)],
['@@INIT', state => fromJS(state)],
[
'COMMIT_ISSUE',
state =>
state.set('committed', state.get('committed').push(state.get('draft'))),
],
[
'UPDATE_ISSUE',
(state, action) =>
state.set('draft', state.get('draft').set(action.key, action.value)),
],
])

export default (state = fromJS({}), action) => {
const INITIAL_STATE = fromJS({
committed: [],
draft: {},
})

export default (state = fromJS([]), action) => {
if (updaters.has(action.type)) {
return updaters.get(action.type)(state, action)
}
Expand Down

0 comments on commit 5a06930

Please sign in to comment.