Browse Source

feature(form): add form reducer

renovate/lint-staged-8.x
Jack Mallers 8 years ago
parent
commit
8324c07b7e
  1. 35
      app/reducers/form.js
  2. 5
      package-lock.json
  3. 1
      package.json

35
app/reducers/form.js

@ -0,0 +1,35 @@
// Constants
// ------------------------------------
export const SET_FORM = 'SET_FORM'
// ------------------------------------
// Actions
// ------------------------------------
export function setForm({ modalOpen, type }) {
return {
type: TOGGLE_MODAL,
modalOpen,
type
}
}
// ------------------------------------
// Action Handlers
// ------------------------------------
const ACTION_HANDLERS = {
[SET_FORM]: (state, { modalOpen, type }) => ({ ...state, modalOpen, type })
}
// ------------------------------------
// Reducer
// ------------------------------------
const initialState = {
modalOpen: false,
type: 'create'
}
export default function formReducer(state = initialState, action) {
const handler = ACTION_HANDLERS[action.type]
return handler ? handler(state, action) : state
}

5
package-lock.json

@ -9282,6 +9282,11 @@
"integrity": "sha1-8OgK4DmkvWVLXygfyT8EqRSn/M4=", "integrity": "sha1-8OgK4DmkvWVLXygfyT8EqRSn/M4=",
"dev": true "dev": true
}, },
"js-search": {
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/js-search/-/js-search-1.4.2.tgz",
"integrity": "sha1-WakeEX1rrbIL8NdkO6dXfVqB1+I="
},
"js-tokens": { "js-tokens": {
"version": "3.0.2", "version": "3.0.2",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz",

1
package.json

@ -187,6 +187,7 @@
"electron-debug": "^1.2.0", "electron-debug": "^1.2.0",
"font-awesome": "^4.7.0", "font-awesome": "^4.7.0",
"history": "^4.6.3", "history": "^4.6.3",
"js-search": "^1.4.2",
"moment-timezone": "^0.5.13", "moment-timezone": "^0.5.13",
"react": "^15.6.1", "react": "^15.6.1",
"react-addons-css-transition-group": "^15.6.0", "react-addons-css-transition-group": "^15.6.0",

Loading…
Cancel
Save