summaryrefslogtreecommitdiff
path: root/client/reducers/currentTask.js
blob: e760fba0b10c55927db1f33db58d2b4977718be2 (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
41
42
43
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