mirror of
https://github.com/zoriya/flood.git
synced 2025-12-22 23:25:27 +00:00
48 lines
1.2 KiB
JavaScript
48 lines
1.2 KiB
JavaScript
import axios from 'axios';
|
|
|
|
import AppDispatcher from '../dispatcher/AppDispatcher';
|
|
import ActionTypes from '../constants/ActionTypes';
|
|
|
|
const SettingsActions = {
|
|
fetchSettings: (property) => {
|
|
return axios.get('/settings', {params: {property}})
|
|
.then((json = {}) => {
|
|
return json.data;
|
|
})
|
|
.then((data) => {
|
|
AppDispatcher.dispatchServerAction({
|
|
type: ActionTypes.SETTINGS_FETCH_REQUEST_SUCCESS,
|
|
data
|
|
});
|
|
})
|
|
.catch((error) => {
|
|
AppDispatcher.dispatchServerAction({
|
|
type: ActionTypes.SETTINGS_FETCH_REQUEST_ERROR,
|
|
error
|
|
});
|
|
});
|
|
},
|
|
|
|
saveSettings: (settings, options = {}) => {
|
|
return axios.patch('/settings', settings)
|
|
.then((json = {}) => {
|
|
return json.data;
|
|
})
|
|
.then((data) => {
|
|
AppDispatcher.dispatchServerAction({
|
|
type: ActionTypes.SETTINGS_SAVE_REQUEST_SUCCESS,
|
|
data,
|
|
options
|
|
});
|
|
})
|
|
.catch((error) => {
|
|
AppDispatcher.dispatchServerAction({
|
|
type: ActionTypes.SETTINGS_SAVE_REQUEST_ERROR,
|
|
error
|
|
});
|
|
});
|
|
}
|
|
};
|
|
|
|
export default SettingsActions;
|