feat: Add Bulk actions to conversations (#4647)
Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
44
app/javascript/dashboard/store/modules/bulkActions.js
Normal file
44
app/javascript/dashboard/store/modules/bulkActions.js
Normal file
@@ -0,0 +1,44 @@
|
||||
import types from '../mutation-types';
|
||||
import BulkActionsAPI from '../../api/bulkActions';
|
||||
|
||||
export const state = {
|
||||
uiFlags: {
|
||||
isUpdating: false,
|
||||
},
|
||||
};
|
||||
|
||||
export const getters = {
|
||||
getUIFlags(_state) {
|
||||
return _state.uiFlags;
|
||||
},
|
||||
};
|
||||
|
||||
export const actions = {
|
||||
process: async function processAction({ commit }, payload) {
|
||||
commit(types.SET_BULK_ACTIONS_FLAG, { isUpdating: true });
|
||||
try {
|
||||
await BulkActionsAPI.create(payload);
|
||||
} catch (error) {
|
||||
throw new Error(error);
|
||||
} finally {
|
||||
commit(types.SET_BULK_ACTIONS_FLAG, { isUpdating: false });
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export const mutations = {
|
||||
[types.SET_BULK_ACTIONS_FLAG](_state, data) {
|
||||
_state.uiFlags = {
|
||||
..._state.uiFlags,
|
||||
...data,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
actions,
|
||||
state,
|
||||
getters,
|
||||
mutations,
|
||||
};
|
||||
Reference in New Issue
Block a user