mirror of
https://github.com/zoriya/flood.git
synced 2026-06-12 06:00:44 +00:00
53 lines
1.2 KiB
JavaScript
53 lines
1.2 KiB
JavaScript
import axios from 'axios';
|
|
|
|
import AppDispatcher from '../dispatcher/AppDispatcher';
|
|
import ActionTypes from '../constants/ActionTypes';
|
|
|
|
const FloodActions = {
|
|
fetchTransferData: () => {
|
|
return axios.get('/stats')
|
|
.then((json = {}) => {
|
|
return json.data;
|
|
})
|
|
.then((transferData) => {
|
|
AppDispatcher.dispatchServerAction({
|
|
type: ActionTypes.CLIENT_FETCH_TRANSFER_DATA_SUCCESS,
|
|
data: {
|
|
transferData
|
|
}
|
|
});
|
|
})
|
|
.catch((error) => {
|
|
AppDispatcher.dispatchServerAction({
|
|
type: ActionTypes.CLIENT_FETCH_TRANSFER_DATA_ERROR,
|
|
data: {
|
|
error
|
|
}
|
|
});
|
|
});
|
|
},
|
|
|
|
fetchTransferHistory: (opts) => {
|
|
return axios.get('/history', {
|
|
params: opts
|
|
})
|
|
.then((json = {}) => {
|
|
return json.data;
|
|
})
|
|
.then((data) => {
|
|
AppDispatcher.dispatchServerAction({
|
|
type: ActionTypes.CLIENT_FETCH_TRANSFER_HISTORY_SUCCESS,
|
|
data
|
|
});
|
|
})
|
|
.catch((error) => {
|
|
AppDispatcher.dispatchServerAction({
|
|
type: ActionTypes.CLIENT_FETCH_TRANSFER_HISTORY_ERROR,
|
|
error
|
|
});
|
|
});
|
|
}
|
|
};
|
|
|
|
export default FloodActions;
|