summaryrefslogtreecommitdiff
path: root/client/reducers
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2017-07-04 04:14:03 +0200
committerJules Laplace <julescarbon@gmail.com>2017-07-04 04:14:03 +0200
commitd520c67839724e80d8b68b8fe933f1e7755a8f42 (patch)
tree51188a9a3b7a125d1e79c899ba7058a280bcde50 /client/reducers
parent2263f412817d6d2d36372e7617feb0d97fa57af8 (diff)
writing task form in a reduxy way
Diffstat (limited to 'client/reducers')
-rw-r--r--client/reducers/currentTask.js41
-rw-r--r--client/reducers/index.js9
2 files changed, 50 insertions, 0 deletions
diff --git a/client/reducers/currentTask.js b/client/reducers/currentTask.js
new file mode 100644
index 0000000..3f9233e
--- /dev/null
+++ b/client/reducers/currentTask.js
@@ -0,0 +1,41 @@
+import { addTask } from '../actions'
+import client from '../client'
+
+const currentTask = (state = {}, action) => {
+ console.log(action.type)
+ switch (action.type) {
+ case 'SET_CONTENT':
+ return {
+ ...state,
+ content: action.file
+ }
+ case 'SET_STYLE':
+ return {
+ ...state,
+ style: action.file
+ }
+ case 'SET_ALPHA':
+ return {
+ ...state,
+ alpha: action.alpha
+ }
+ case 'CREATE_TASK':
+ client.task.create( state ).then( (data) => {
+ addTask( data )
+ })
+
+ return {
+ content: null,
+ style: null,
+ alpha: state.alpha,
+ }
+// case 'ADD_TASK':
+// return {
+// ...state
+// }
+ default:
+ return state
+ }
+}
+
+export default currentTask \ No newline at end of file
diff --git a/client/reducers/index.js b/client/reducers/index.js
new file mode 100644
index 0000000..ed59b60
--- /dev/null
+++ b/client/reducers/index.js
@@ -0,0 +1,9 @@
+import { combineReducers } from 'redux'
+
+import currentTask from './currentTask'
+
+const cortexApp = combineReducers({
+ currentTask
+})
+
+export default cortexApp