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

export default promiseImg;
