summaryrefslogtreecommitdiff
path: root/client/reducers/currentTask.js
blob: 126c35df678d97f61d9068cc0cee93f415eb6caa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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',
        tool: 'nsatf',
        completed: false,
      }
      client.task.create( record ).then( (data) => {
        data.content_file = state.content
        data.style_file = state.file
        // store.dispatch( addTask( data ) )
      })
      return state
    default:
      return state
  }
}

export default currentTask