2021-06-17 20:10:29 -04:00
|
|
|
import createFlash from '~/flash';
|
2019-10-28 14:06:15 -04:00
|
|
|
import { __ } from '~/locale';
|
|
|
|
import service from '../services/contributors_service';
|
|
|
|
import * as types from './mutation_types';
|
|
|
|
|
|
|
|
export const fetchChartData = ({ commit }, endpoint) => {
|
|
|
|
commit(types.SET_LOADING_STATE, true);
|
|
|
|
|
|
|
|
return service
|
|
|
|
.fetchChartData(endpoint)
|
2020-12-23 16:10:24 -05:00
|
|
|
.then((res) => res.data)
|
|
|
|
.then((data) => {
|
2019-10-28 14:06:15 -04:00
|
|
|
commit(types.SET_CHART_DATA, data);
|
|
|
|
commit(types.SET_LOADING_STATE, false);
|
|
|
|
})
|
2021-06-17 20:10:29 -04:00
|
|
|
.catch(() =>
|
|
|
|
createFlash({
|
|
|
|
message: __('An error occurred while loading chart data'),
|
|
|
|
}),
|
|
|
|
);
|
2019-10-28 14:06:15 -04:00
|
|
|
};
|