110 lines
2.4 KiB
JavaScript
Raw Normal View History

2016-09-25 21:54:59 +02:00
/*
* App Actions
*
* Actions change things in your application
* Since this boilerplate uses a uni-directional data flow, specifically redux,
* we have these actions which are the only way your application interacts with
* your application state. This guarantees that your state is up to date and nobody
* messes it up weirdly somewhere.
*
* To add a new Action:
* 1) Import your constant
* 2) Add a function like this:
* export function yourAction(var) {
* return { type: YOUR_ACTION_CONSTANT, var: var }
* }
*/
import {
LOAD_GENERAL_SETTINGS,
LOAD_GENERAL_SETTINGS_SUCCESS,
LOAD_GENERAL_SETTINGS_ERROR,
2016-09-26 18:28:32 +02:00
CHANGE_NAME,
CHANGE_DESCRIPTION,
CHANGE_VERSION,
2016-09-26 17:28:40 +02:00
UPDATE_GENERAL_SETTINGS,
2016-09-27 18:06:35 +02:00
UPDATE_GENERAL_SETTINGS_SUCCESS,
UPDATE_GENERAL_SETTINGS_ERROR,
2016-09-25 21:54:59 +02:00
} from './constants';
/**
* Load the generalSettings, this action starts the request saga
*
* @return {object} An action object with a type of LOAD_GENERAL_SETTINGS
*/
export function loadGeneralSettings() {
return {
type: LOAD_GENERAL_SETTINGS,
};
}
/**
* Dispatched when the generalSettings are loaded by the request saga
*
* @param {array} generalSettings The generalSettings data
* @param {string} username The current username
*
* @return {object} An action object with a type of LOAD_GENERAL_SETTINGS_SUCCESS passing the generalSettings
*/
2016-09-26 17:28:40 +02:00
export function generalSettingsLoaded(data) {
2016-09-25 21:54:59 +02:00
return {
type: LOAD_GENERAL_SETTINGS_SUCCESS,
2016-09-26 17:28:40 +02:00
data,
2016-09-25 21:54:59 +02:00
};
}
/**
2016-09-26 17:28:40 +02:00
* Dispatched when loading the generalSettings fails
2016-09-25 21:54:59 +02:00
*
* @param {object} error The error
*
* @return {object} An action object with a type of LOAD_GENERAL_SETTINGS_ERROR passing the error
*/
export function generalSettingsLoadingError(error) {
return {
type: LOAD_GENERAL_SETTINGS_ERROR,
error,
};
}
2016-09-26 17:28:40 +02:00
export function changeName(name) {
return {
2016-09-26 18:28:32 +02:00
type: CHANGE_NAME,
2016-09-26 17:28:40 +02:00
name: name
};
}
2016-09-26 18:28:32 +02:00
export function changeDescription(description) {
return {
type: CHANGE_DESCRIPTION,
description: description
};
}
export function changeVersion(version) {
return {
type: CHANGE_VERSION,
version: version
};
}
2016-09-26 17:28:40 +02:00
export function updateGeneralSettings(data) {
return {
type: UPDATE_GENERAL_SETTINGS,
data: data
}
2016-09-27 18:06:35 +02:00
}
export function generalSettingsUpdated(data) {
return {
type: UPDATE_GENERAL_SETTINGS_SUCCESS,
data: data
}
}
export function generalSettingsUpdatedError(error) {
return {
type: UPDATE_GENERAL_SETTINGS_ERROR,
error: error
}
2016-09-26 17:28:40 +02:00
}