From d520c67839724e80d8b68b8fe933f1e7755a8f42 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 4 Jul 2017 04:14:03 +0200 Subject: writing task form in a reduxy way --- client/reducers/currentTask.js | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 client/reducers/currentTask.js (limited to 'client/reducers/currentTask.js') 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 -- cgit v1.2.3-70-g09d2