From 5a0693079083f805980ff4df655b476d8d6aee53 Mon Sep 17 00:00:00 2001 From: Daniel Playfair Cal Date: Fri, 13 Oct 2017 14:45:46 +1100 Subject: [PATCH] Add issues store and submit handler --- src/actions/index.js | 4 ++++ src/components/Admin.js | 39 +++++++++++++++++++++++++++++---------- src/reducers/issues.js | 17 ++++++++++++++++- 3 files changed, 49 insertions(+), 11 deletions(-) diff --git a/src/actions/index.js b/src/actions/index.js index b9a4529..9aabe55 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -28,3 +28,7 @@ export const visitVideo = slug => ({ type: 'VIDEO', payload: { slug }, }) + +export const commitIssue = () => ({ + type: 'COMMIT_ISSUE', +}) diff --git a/src/components/Admin.js b/src/components/Admin.js index 6d9debf..c9df1e3 100644 --- a/src/components/Admin.js +++ b/src/components/Admin.js @@ -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 = () => -
- - -
- - -
-
+class _MeetingAgenda extends PureComponent { + onSubmit = () => {} + + render() { + return ( +
+ + +
+ + +
+
+ ) + } +} + +const MeetingAgenda = connect( + () => ({}), + dispatch => + ({ + onSubmit: () => dispatch(commitIssue()), + }(_MeetingAgenda)) +) export default MeetingAgenda diff --git a/src/reducers/issues.js b/src/reducers/issues.js index 1409622..982f69c 100644 --- a/src/reducers/issues.js +++ b/src/reducers/issues.js @@ -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) }