Sha256: 18e6e93e3d4a45569b92b067bf144149f0f915fd34cc81dff5527e2882aebdf7

Contents?: true

Size: 721 Bytes

Versions: 82

Compression:

Stored size: 721 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

82 entries across 82 versions & 1 rubygems

Version Path
foreman_rh_cloud-10.0.3 webpack/__mocks__/foremanReact/redux/API/APISelectors.js
foreman_rh_cloud-11.0.3 webpack/__mocks__/foremanReact/redux/API/APISelectors.js
foreman_rh_cloud-9.0.59 webpack/__mocks__/foremanReact/redux/API/APISelectors.js
foreman_rh_cloud-11.0.2 webpack/__mocks__/foremanReact/redux/API/APISelectors.js
foreman_rh_cloud-11.0.1 webpack/__mocks__/foremanReact/redux/API/APISelectors.js
foreman_rh_cloud-11.0.0 webpack/__mocks__/foremanReact/redux/API/APISelectors.js
foreman_rh_cloud-9.0.58 webpack/__mocks__/foremanReact/redux/API/APISelectors.js
foreman_rh_cloud-10.0.2 webpack/__mocks__/foremanReact/redux/API/APISelectors.js
foreman_rh_cloud-9.0.57 webpack/__mocks__/foremanReact/redux/API/APISelectors.js
foreman_rh_cloud-10.0.1 webpack/__mocks__/foremanReact/redux/API/APISelectors.js
foreman_rh_cloud-9.0.56 webpack/__mocks__/foremanReact/redux/API/APISelectors.js
foreman_rh_cloud-9.0.55 webpack/__mocks__/foremanReact/redux/API/APISelectors.js
foreman_rh_cloud-9.0.54 webpack/__mocks__/foremanReact/redux/API/APISelectors.js
foreman_rh_cloud-9.0.53 webpack/__mocks__/foremanReact/redux/API/APISelectors.js
foreman_rh_cloud-9.0.52 webpack/__mocks__/foremanReact/redux/API/APISelectors.js
foreman_rh_cloud-8.0.52 webpack/__mocks__/foremanReact/redux/API/APISelectors.js
foreman_rh_cloud-9.0.51 webpack/__mocks__/foremanReact/redux/API/APISelectors.js
foreman_rh_cloud-8.0.51 webpack/__mocks__/foremanReact/redux/API/APISelectors.js
foreman_rh_cloud-7.0.48 webpack/__mocks__/foremanReact/redux/API/APISelectors.js
foreman_rh_cloud-7.0.47 webpack/__mocks__/foremanReact/redux/API/APISelectors.js