From 8324c07b7e56342fbcb5b8b66af274300747dea8 Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Fri, 28 Jul 2017 19:22:10 -0500 Subject: [PATCH] feature(form): add form reducer --- app/reducers/form.js | 35 +++++++++++++++++++++++++++++++++++ package-lock.json | 5 +++++ package.json | 1 + 3 files changed, 41 insertions(+) create mode 100644 app/reducers/form.js diff --git a/app/reducers/form.js b/app/reducers/form.js new file mode 100644 index 00000000..75569925 --- /dev/null +++ b/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 +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 3ab22b9a..5bb3761a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9282,6 +9282,11 @@ "integrity": "sha1-8OgK4DmkvWVLXygfyT8EqRSn/M4=", "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": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", diff --git a/package.json b/package.json index 9875e0d7..0bcfcc8d 100644 --- a/package.json +++ b/package.json @@ -187,6 +187,7 @@ "electron-debug": "^1.2.0", "font-awesome": "^4.7.0", "history": "^4.6.3", + "js-search": "^1.4.2", "moment-timezone": "^0.5.13", "react": "^15.6.1", "react-addons-css-transition-group": "^15.6.0",