summaryrefslogtreecommitdiff
path: root/client/reducers/tasks.js
blob: 9edd82a22cf7f6dbd671a9f09ec4553b9ba82590 (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
// import { addTask } from '../actions'
import client from '../client'

const tasks = (state = [], action) => {
  switch (action.type) {
    case 'LOAD_TASKS':
      return action.tasks
    case 'ADD_TASK':
      console.log(action)
      return state.concat([action.task])
    case 'TASK_UPDATED':
      const updated_tasks = state.map(task => {
        if (task.id == id) {
          return task
        }
        return id
      })
      return updated_tasks
    default:
      return state
  }
}

export default tasks