summaryrefslogtreecommitdiff
path: root/app/client/dataset/upload.reducer.js
blob: e28a18eb82996c0c337fb8353b9b5a15ab7a6e73 (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
44
45
46
47
48
49
50
51
52
import types from '../types'

const uploadInitialState = {
  loading: false,
  error: null,
  status: '',
}

const uploadReducer = (state = uploadInitialState, action) => {
  switch(action.type) {
    case types.folder.upload_loading:
      return {
        error: null,
        loading: true,
        status: 'Loading...',
      }
    case types.folder.upload_error:
      return {
        error: null,
        loading: false,
        status: 'Error uploading :(',
      }
    case types.folder.upload_progress:
      return {
        error: null,
        loading: true,
        status: 'Upload progress ' + action.percent + '%',
      }
    case types.folder.upload_waiting:
      return {
        error: null,
        loading: true,
        status: 'Waiting for server to finish processing...',
      }
    case types.folder.upload_complete:
      return {
        error: null,
        loading: false,
        status: 'Upload complete',
      }
    case types.file.create_loading:
      return {
        error: null,
        loading: true,
        status: 'Creating file...'
      }
    default:
      return state
  }
}

export default uploadReducer