Created
June 14, 2019 23:17
-
-
Save zackshapiro/1866206d9bb9368326cbbb4f4b5c64c2 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 '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