import { addTask } from '../actions' import client from '../client' const currentTask = (state = {}, action) => { 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': const record = { content_file_id: state.content.id, style_file_id: state.style.id, alpha: state.alpha || '0.001', command: 'nsatf.py', completed: false, } client.task.create( record ).then( (data) => { addTask( data ) }) return state // case 'ADD_TASK': // return { // ...state // } default: return state } } export default currentTask