Sha256: ecbef275abf6c302b40996bb6a972fb52468094dfce18e268695f646200b7281

Contents?: true

Size: 715 Bytes

Versions: 3

Compression:

Stored size: 715 Bytes

Contents

import { STATUS } from '../../constants';

export const selectAPI = state => state.API;

export const selectAPIByKey = (state, key) => selectAPI(state)[key] || {};

export const selectAPIStatus = (state, key) =>
  selectAPIByKey(state, key).status;

export const selectAPIPayload = (state, key) =>
  selectAPIByKey(state, key).payload || {};

export const selectAPIResponse = (state, key) =>
  selectAPIByKey(state, key).response || {};

export const selectAPIError = (state, key) =>
  selectAPIStatus(state, key) === STATUS.ERROR
    ? selectAPIResponse(state, key)
    : null;

export const selectAPIErrorMessage = (state, key) => {
  const error = selectAPIError(state, key);
  return error && error.message;
};

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
foreman_rh_cloud-3.0.17 webpack/__mocks__/foremanReact/redux/API/APISelectors.js
foreman_rh_cloud-3.0.16 webpack/__mocks__/foremanReact/redux/API/APISelectors.js
foreman_rh_cloud-3.0.15 webpack/__mocks__/foremanReact/redux/API/APISelectors.js