Created
June 14, 2019 23:17
-
-
Save zackshapiro/2d76abf1971481743be21b5070fe9b7f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const reducer = (state, action) => { | |
switch (action.type) { | |
case 'load': | |
return { ...state, files: action.files, status: LOADED } | |
case 'submit': | |
return { ...state, uploading: true, pending: state.files, status: INIT } | |
case 'next': | |
return { | |
...state, | |
next: action.next, | |
status: PENDING, | |
} | |
case 'file-uploaded': | |
return { | |
...state, | |
next: null, | |
pending: action.pending, | |
uploaded: { | |
...state.uploaded, | |
[action.prev.id]: action.prev.file, | |
}, | |
} | |
case 'files-uploaded': | |
return { ...state, uploading: false, status: FILES_UPLOADED } | |
case 'set-upload-error': | |
return { ...state, uploadError: action.error, status: UPLOAD_ERROR } | |
default: | |
return state | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment