Commit 048b0453 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Added mutations and actions for tasks_by_type

parent 5bf5e35a
......@@ -192,3 +192,22 @@ export const createCustomStage = ({ dispatch, state }, data) => {
.then(response => dispatch('receiveCreateCustomStageSuccess', response))
.catch(error => dispatch('receiveCreateCustomStageError', { error, data }));
};
export const receiveTasksByTypeSuccess = ({ commit }, data) =>
commit(types.RECEIVE_TASKS_BY_TYPE_SUCCESS, data);
export const receiveTasksByTypeError = ({ commit }, error) => {
commit(types.RECEIVE_TASKS_BY_TYPE_ERROR, error);
createFlash(__('There was an error fetching data for the form'));
};
export const requestTasksByType = ({ commit }) => commit(types.REQUEST_TASKS_BY_TYPE);
export const fetchTasksByType = ({ dispatch }, { groupPath, labelIds }) => {
const endpoint = '/~/analytics/tasks_by_type';
const params = { group_id: groupPath, label_ids: labelIds };
dispatch('requestTasksByTypeData');
return axios
.get(endpoint, params)
.then(data => dispatch('receiveTasksByTypeSuccess', data))
.catch(error => dispatch('receiveTasksByTypeError', error));
};
......@@ -32,3 +32,7 @@ export const RECEIVE_GROUP_STAGES_AND_EVENTS_ERROR = 'RECEIVE_GROUP_STAGES_AND_E
export const REQUEST_CREATE_CUSTOM_STAGE = 'REQUEST_CREATE_CUSTOM_STAGE';
export const RECEIVE_CREATE_CUSTOM_STAGE_RESPONSE = 'RECEIVE_CREATE_CUSTOM_STAGE_RESPONSE';
export const REQUEST_TASKS_BY_TYPE_DATA = 'REQUEST_TASKS_BY_TYPE_DATA';
export const RECEIVE_TASKS_BY_TYPE_DATA_SUCCESS = 'RECEIVE_TASKS_BY_TYPE_DATA_SUCCESS';
export const RECEIVE_TASKS_BY_TYPE_DATA_ERROR = 'RECEIVE_TASKS_BY_TYPE_DATA_ERROR';
......@@ -126,4 +126,7 @@ export default {
[types.RECEIVE_CREATE_CUSTOM_STAGE_RESPONSE](state) {
state.isSavingCustomStage = false;
},
[types.REQUEST_TASKS_BY_TYPE_DATA](state) {},
[types.REQUEST_TASKS_BY_TYPE_DATA_ERROR](state) {},
[types.REQUEST_TASKS_BY_TYPE_DATA_SUCCESS](state) {},
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment