All files / app/assets/javascripts/members/store actions.js

100% Statements 19/19
100% Branches 4/4
100% Functions 6/6
100% Lines 19/19

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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54        4x       3x 3x         1x   1x       4x 1x     4x 1x     4x 1x     4x 1x     4x 3x 3x         2x         1x   1x      
import axios from '~/lib/utils/axios_utils';
import { formatDate } from '~/lib/utils/datetime_utility';
import * as types from './mutation_types';
 
export const updateMemberRole = async (
  { state, commit },
  { memberId, accessLevel, memberRoleId },
) => {
  try {
    return await axios.put(
      state.memberPath.replace(/:id$/, memberId),
      state.requestFormatter({ accessLevel, memberRoleId }),
    );
  } catch (error) {
    commit(types.RECEIVE_MEMBER_ROLE_ERROR, { error });
 
    throw error;
  }
};
 
export const showRemoveGroupLinkModal = ({ commit }, groupLink) => {
  commit(types.SHOW_REMOVE_GROUP_LINK_MODAL, groupLink);
};
 
export const hideRemoveGroupLinkModal = ({ commit }) => {
  commit(types.HIDE_REMOVE_GROUP_LINK_MODAL);
};
 
export const showRemoveMemberModal = ({ commit }, modalData) => {
  commit(types.SHOW_REMOVE_MEMBER_MODAL, modalData);
};
 
export const hideRemoveMemberModal = ({ commit }) => {
  commit(types.HIDE_REMOVE_MEMBER_MODAL);
};
 
export const updateMemberExpiration = async ({ state, commit }, { memberId, expiresAt }) => {
  try {
    await axios.put(
      state.memberPath.replace(':id', memberId),
      state.requestFormatter({ expires_at: expiresAt ? formatDate(expiresAt, 'isoDate') : '' }),
    );
 
    commit(types.RECEIVE_MEMBER_EXPIRATION_SUCCESS, {
      memberId,
      expiresAt: expiresAt ? formatDate(expiresAt, 'isoUtcDateTime') : null,
    });
  } catch (error) {
    commit(types.RECEIVE_MEMBER_EXPIRATION_ERROR, { error });
 
    throw error;
  }
};