uploaderReducer.js 368 B

1234567891011121314
  1. function upLoaderReducer (state = {}, { type, name, status, payload, error }) {
  2. if (type === 'UPLOAD_IMG_CLEAR') {
  3. return {};
  4. }
  5. if (type === 'UPLOAD') {
  6. return {
  7. ...state,
  8. [name]: { status, payload: (status === 'PENDING' && state[name] && state[name].payload) || payload, error }
  9. };
  10. }
  11. return state;
  12. }
  13. export default upLoaderReducer;