summaryrefslogtreecommitdiff
path: root/client/reducers/newFolder.js
blob: 5c0f40dfd78e7ef76cdefa9dc2480db9a0f35e29 (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
import client from '../client'

const newFolder = (state = {}, action) => {
  switch (action.type) {
    case 'INIT_NEW_FOLDER':
      return {
        name: '',
        visible: true,
      }

    case 'CANCEL_NEW_FOLDER':
      return {
        name: '',
        visible: false,
      }

    case 'CREATE_NEW_FOLDER':
      if (action.name) {
        client.folder.create({ name: action.name })
        .then(action.cb)
      }
      return {
        name: '',
        visible: false,
      }
    
    default:
      return state
  }
}

export default newFolder