All files / ee/app/assets/javascripts/billings/subscriptions/store actions.js

100% Statements 14/14
100% Branches 0/0
100% Functions 7/7
100% Lines 13/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32          4x 1x           4x 2x   2x 1x 1x     4x   4x 1x   4x 1x     1x    
import Api from 'ee/api';
import { createAlert } from '~/alert';
import { s__ } from '~/locale';
import * as types from './mutation_types';
 
export const setNamespaceId = ({ commit }, namespaceId) => {
  commit(types.SET_NAMESPACE_ID, namespaceId);
};
 
/**
 * Subscription Table
 */
export const fetchSubscription = ({ dispatch, state }) => {
  dispatch('requestSubscription');
 
  return Api.userSubscription(state.namespaceId)
    .then(({ data }) => dispatch('receiveSubscriptionSuccess', data))
    .catch(() => dispatch('receiveSubscriptionError'));
};
 
export const requestSubscription = ({ commit }) => commit(types.REQUEST_SUBSCRIPTION);
 
export const receiveSubscriptionSuccess = ({ commit }, response) =>
  commit(types.RECEIVE_SUBSCRIPTION_SUCCESS, response);
 
export const receiveSubscriptionError = ({ commit }) => {
  createAlert({
    message: s__('SubscriptionTable|An error occurred while loading the subscription details.'),
  });
  commit(types.RECEIVE_SUBSCRIPTION_ERROR);
};