diff options
Diffstat (limited to 'app/assets/javascripts/vuex_shared/modules/members/actions.js')
-rw-r--r-- | app/assets/javascripts/vuex_shared/modules/members/actions.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/app/assets/javascripts/vuex_shared/modules/members/actions.js b/app/assets/javascripts/vuex_shared/modules/members/actions.js index f7fdddfd070..4c31b3c9744 100644 --- a/app/assets/javascripts/vuex_shared/modules/members/actions.js +++ b/app/assets/javascripts/vuex_shared/modules/members/actions.js @@ -1,5 +1,6 @@ import * as types from './mutation_types'; import axios from '~/lib/utils/axios_utils'; +import { formatDate } from '~/lib/utils/datetime_utility'; export const updateMemberRole = async ({ state, commit }, { memberId, accessLevel }) => { try { @@ -23,3 +24,21 @@ export const showRemoveGroupLinkModal = ({ commit }, groupLink) => { export const hideRemoveGroupLinkModal = ({ commit }) => { commit(types.HIDE_REMOVE_GROUP_LINK_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); + + throw error; + } +}; |