+ client: handle clear statistics

This commit is contained in:
Ildar Kamalov
2019-08-30 18:35:27 +03:00
parent 883910c19e
commit 63049e0521
8 changed files with 91 additions and 34 deletions

View File

@@ -59,3 +59,19 @@ export const getStats = () => async (dispatch) => {
dispatch(getStatsFailure());
}
};
export const resetStatsRequest = createAction('RESET_STATS_REQUEST');
export const resetStatsFailure = createAction('RESET_STATS_FAILURE');
export const resetStatsSuccess = createAction('RESET_STATS_SUCCESS');
export const resetStats = () => async (dispatch) => {
dispatch(getStatsRequest());
try {
await apiClient.resetStats();
dispatch(addSuccessToast('statistics_cleared'));
dispatch(resetStatsSuccess());
} catch (error) {
dispatch(addErrorToast({ error }));
dispatch(resetStatsFailure());
}
};