actions.js
export const getSeverityDistData = (dispatch, urlqueryStr) => {
handleFetch(
{
...getSeverityDist(),
urlqueryStr,
}, // fetch params
(res) => {
dispatch({
type: ActionTypes.GET_DASHBOARD_LIST_SUCCESS,
payload: {
data: res.data,
isLoading: false,
onError: false,
},
});
},
(e) => {
dispatch({
type: ActionTypes.GET_DASHBOARD_LIST_ERROR,
payload: {
errorMsg: e.message,
isLoading: false,
},
});
},
(loading) => {
dispatch({
type: ActionTypes.GET_DASHBOARD_LIST_LOADING,
payload: loading,
});
}
);};
export const getGroupData = (dispatch, urlqueryStr) => {
handleFetch(
{
...getGruop(),
urlqueryStr,
},//...sameOperations SameActionTypes...}
reducers.js
const setChartsData = (state, action) => ({
...state,
data: [...action.payload.data],
isLoading: action.payload.isLoading,
onError: action.payload.onError,
});
const setLoading = (state, action) => ({
...state,
isLoading: action.payload,
});
const setTimeOut = (state, action) => ({
...state,
isTimeout: action.payload,
});
const onError = (state, action) => ({
...state,
onError: action.payload.errorMsg,
isLoading: action.payload.isLoading,
});
const initialState = {
data: [],
isLoading: false,
isTimeout: false,
onError: '',
};
export default (state = initialState, action) => {
switch (action.type) {
case ActionTypes.GET_DASHBOARD_LIST_SUCCESS:
return setChartsData(state, action);
case ActionTypes.GET_DASHBOARD_LIST_LOADING:
return setLoading(state, action);
case ActionTypes.GET_DASHBOARD_LIST_TIME_OUT:
return setTimeOut(state, action);
case ActionTypes.GET_DASHBOARD_LIST_ERROR:
return onError(state, action);
default:
return state;
}
};
Let me tell you briefly what I want to do. Consider 2 charts on one page. The data coming to these charts is from different api but according to the same filter by the ui. For example, the user will select certain parameters from the filter section and a query will be sent to the APIs according to this filter status, each API will return a data of its own and these different data will be displayed in different graphs on the same page. What I want to do is to separate the data from the API by graphs. When I make a transaction as I wrote above, the values I withdraw from the store change. I guess whichever one comes up overwrites the other. How can I get out of this situation?