Sha256: e2680048762a4a8ca619c82406c3817bb5c884be4c425172bce64c3486312483
Contents?: true
Size: 1.37 KB
Versions: 8
Compression:
Stored size: 1.37 KB
Contents
import { API_OPERATIONS, get, put } from 'foremanReact/redux/API'; import { addToast } from 'foremanReact/redux/actions/toasts'; import { translate as __ } from 'foremanReact/common/I18n'; import CONTENT_VIEWS_KEY, { UPDATE_CONTENT_VIEW, UPDATE_CONTENT_VIEW_FAILURE, UPDATE_CONTENT_VIEW_SUCCESS, } from '../ContentViewsConstants'; import api from '../../../services/api'; import { apiError } from '../../../utils/helpers'; const getContentViewDetails = cvId => get({ type: API_OPERATIONS.GET, key: `${CONTENT_VIEWS_KEY}_${cvId}`, url: api.getApiUrl(`/content_views/${cvId}`), }); const cvUpdateSuccess = (response, dispatch) => { const { data: { id } } = response; // Update CV info in redux with the updated CV info from API dispatch(getContentViewDetails(id)); return dispatch(addToast({ type: 'success', message: __(' Content view updated.'), })); }; export const updateContentView = (cvId, params) => async dispatch => dispatch(put({ type: API_OPERATIONS.PUT, key: `${CONTENT_VIEWS_KEY}_${cvId}`, url: api.getApiUrl(`/content_views/${cvId}`), params, handleSuccess: response => cvUpdateSuccess(response, dispatch), handleError: error => dispatch(apiError(null, error)), actionTypes: { REQUEST: UPDATE_CONTENT_VIEW, SUCCESS: UPDATE_CONTENT_VIEW_SUCCESS, FAILURE: UPDATE_CONTENT_VIEW_FAILURE, }, })); export default getContentViewDetails;
Version data entries
8 entries across 8 versions & 1 rubygems