-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathrespondentsFiles.js
More file actions
41 lines (39 loc) · 919 Bytes
/
Copy pathrespondentsFiles.js
File metadata and controls
41 lines (39 loc) · 919 Bytes
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
import * as actions from "../actions/survey"
const markAsCreating = (files, creatingFile) => ({
...files,
[creatingFile]: {
...files[creatingFile],
file_type: creatingFile,
creating: true,
created_at: null,
}
})
export default (state = {}, action) => {
switch (action.type) {
case actions.GENERATING_FILE:
return {
...state,
files: markAsCreating(state.files || {}, action.file),
}
case actions.FETCHING_FILES_STATUS:
if (action.surveyId != state.surveyId) {
return {
...state,
surveyId: null,
surveyState: null,
files: null,
}
} else {
return state
}
case actions.RECEIVE_FILES_STATUS:
return {
...state,
surveyId: action.surveyId,
surveyState: action.surveyState,
files: action.files,
}
default:
return state
}
}