2017-11-07 14:32:31 +01:00
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
* EditPage actions
|
|
|
|
|
*
|
|
|
|
|
*/
|
2017-11-15 14:00:51 +01:00
|
|
|
import { List, Map } from 'immutable';
|
2017-11-07 14:32:31 +01:00
|
|
|
import {
|
2017-11-07 18:16:42 +01:00
|
|
|
ADD_USER,
|
2017-11-15 14:00:51 +01:00
|
|
|
GET_ROLE,
|
|
|
|
|
GET_ROLE_SUCCEEDED,
|
2017-11-07 16:33:15 +01:00
|
|
|
ON_CANCEL,
|
|
|
|
|
ON_CHANGE_INPUT,
|
2017-11-07 18:16:42 +01:00
|
|
|
ON_CLICK_DELETE,
|
2017-11-15 14:00:51 +01:00
|
|
|
SET_FORM,
|
2017-11-07 14:32:31 +01:00
|
|
|
} from './constants';
|
|
|
|
|
|
2017-11-07 18:16:42 +01:00
|
|
|
export function addUser(newUser) {
|
|
|
|
|
return {
|
|
|
|
|
type: ADD_USER,
|
|
|
|
|
newUser,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-15 14:00:51 +01:00
|
|
|
export function getRole() {
|
|
|
|
|
return {
|
|
|
|
|
type: GET_ROLE,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function getRoleSucceeded(data) {
|
|
|
|
|
return {
|
|
|
|
|
type: GET_ROLE_SUCCEEDED,
|
|
|
|
|
data,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-07 16:33:15 +01:00
|
|
|
export function onCancel() {
|
2017-11-07 14:32:31 +01:00
|
|
|
return {
|
2017-11-07 16:33:15 +01:00
|
|
|
type: ON_CANCEL,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function onChangeInput({ target }) {
|
|
|
|
|
return {
|
|
|
|
|
type: ON_CHANGE_INPUT,
|
|
|
|
|
key: target.name,
|
|
|
|
|
value: target.value,
|
2017-11-07 14:32:31 +01:00
|
|
|
};
|
|
|
|
|
}
|
2017-11-07 18:16:42 +01:00
|
|
|
|
|
|
|
|
export function onClickDelete(itemToDelete) {
|
|
|
|
|
return {
|
|
|
|
|
type: ON_CLICK_DELETE,
|
|
|
|
|
itemToDelete,
|
|
|
|
|
};
|
|
|
|
|
}
|
2017-11-15 14:00:51 +01:00
|
|
|
|
|
|
|
|
export function setForm() {
|
|
|
|
|
const form = Map({
|
|
|
|
|
name: '',
|
|
|
|
|
description: '',
|
|
|
|
|
users: List([
|
|
|
|
|
{ name: 'Pierre Burgy' },
|
|
|
|
|
{ name: 'Jim Laurie' },
|
|
|
|
|
{ name: 'Aurelien Georget' },
|
|
|
|
|
{ name: 'Cyril Lopez' },
|
|
|
|
|
]),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
type: SET_FORM,
|
|
|
|
|
form,
|
|
|
|
|
};
|
|
|
|
|
}
|