Sha256: 8e63baa67153dbf11a172e4bb201a4b5afce4d274be59738a7913f210eb45339
Contents?: true
Size: 1.46 KB
Versions: 14
Compression:
Stored size: 1.46 KB
Contents
import { propsToSnakeCase } from 'foremanReact/common/helpers'; import api, { orgId } from '../../services/api'; import { GET_ORGANIZATION_REQUEST, GET_ORGANIZATION_SUCCESS, GET_ORGANIZATION_FAILURE, SAVE_ORGANIZATION_REQUEST, SAVE_ORGANIZATION_SUCCESS, SAVE_ORGANIZATION_FAILURE, } from './OrganizationConstants'; export const loadOrganization = (extendedParams = {}) => (dispatch) => { dispatch({ type: GET_ORGANIZATION_REQUEST }); const params = { ...propsToSnakeCase(extendedParams), }; return api .get(`/organizations/${orgId()}`, {}, params) .then(({ data }) => { dispatch({ type: GET_ORGANIZATION_SUCCESS, response: data, }); }) .catch((result) => { dispatch({ type: GET_ORGANIZATION_FAILURE, result, }); }); }; export const saveOrganization = (extendedParams = {}) => (dispatch) => { dispatch({ type: SAVE_ORGANIZATION_REQUEST }); const params = { ...{ id: orgId() }, ...propsToSnakeCase(extendedParams), }; return api .put(`/organizations/${orgId()}`, params) .then(({ data }) => { dispatch({ type: SAVE_ORGANIZATION_SUCCESS, response: data, }); // TODO: Necessary because of https://projects.theforeman.org/issues/26420 dispatch(loadOrganization()); }) .catch((result) => { dispatch({ type: SAVE_ORGANIZATION_FAILURE, result, }); }); }; export default loadOrganization;
Version data entries
14 entries across 14 versions & 1 rubygems