function upLoaderReducer (state = {}, { type, name, status, payload, error }) {
  if (type === 'UPLOAD_IMG_CLEAR') {
    return {};
  }
  if (type === 'UPLOAD') {
    return {
      ...state,
      [name]: { status, payload: (status === 'PENDING' && state[name] && state[name].payload) || payload, error }
    };
  }
  return state;
}

export default upLoaderReducer;
