2018-02-08 12:01:06 +01:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* HomePage actions
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2018-02-16 14:17:24 +01:00
|
|
|
import {
|
2018-02-19 15:14:32 +01:00
|
|
|
CHANGE_PARAMS,
|
|
|
|
DELETE_DATA,
|
|
|
|
DELETE_SUCCESS,
|
2018-02-16 14:17:24 +01:00
|
|
|
DROP_SUCCESS,
|
2018-02-16 15:39:35 +01:00
|
|
|
GET_DATA,
|
|
|
|
GET_DATA_SUCCESS,
|
2018-02-16 14:17:24 +01:00
|
|
|
ON_DROP,
|
|
|
|
ON_SEARCH,
|
2018-02-23 15:28:01 +01:00
|
|
|
ON_SEARCH_SUCCESS,
|
2018-03-06 09:31:44 +01:00
|
|
|
SET_LOADING,
|
2018-02-23 12:21:57 +01:00
|
|
|
SET_PARAMS,
|
2018-03-06 09:31:44 +01:00
|
|
|
UNSET_LOADING,
|
2018-02-16 14:17:24 +01:00
|
|
|
} from './constants';
|
|
|
|
|
2018-02-19 15:14:32 +01:00
|
|
|
export function changeParams({ target }) {
|
|
|
|
return {
|
|
|
|
type: CHANGE_PARAMS,
|
|
|
|
keys: target.name.split('.'),
|
|
|
|
value: target.value,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function deleteData(dataToDelete) {
|
|
|
|
return {
|
|
|
|
type: DELETE_DATA,
|
|
|
|
dataToDelete,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function deleteSuccess() {
|
|
|
|
return {
|
|
|
|
type: DELETE_SUCCESS,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-02-16 14:17:24 +01:00
|
|
|
export function dropSuccess(newFiles) {
|
|
|
|
return {
|
|
|
|
type: DROP_SUCCESS,
|
|
|
|
newFiles,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-02-16 15:39:35 +01:00
|
|
|
export function getData() {
|
|
|
|
return {
|
|
|
|
type: GET_DATA,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getDataSuccess(data, entriesNumber) {
|
|
|
|
return {
|
|
|
|
type: GET_DATA_SUCCESS,
|
|
|
|
data,
|
|
|
|
entriesNumber,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-02-16 14:17:24 +01:00
|
|
|
export function onDrop({ dataTransfer: { files } }) {
|
2018-02-22 18:24:17 +01:00
|
|
|
const formData = Object.keys(files).reduce((acc, current) => {
|
|
|
|
acc.append('files', files[current]);
|
2020-01-24 15:39:14 +01:00
|
|
|
|
2018-02-22 18:24:17 +01:00
|
|
|
return acc;
|
|
|
|
}, new FormData());
|
|
|
|
|
2018-02-16 14:17:24 +01:00
|
|
|
return {
|
|
|
|
type: ON_DROP,
|
2018-02-22 18:24:17 +01:00
|
|
|
formData,
|
2018-02-22 12:08:11 +01:00
|
|
|
};
|
2018-02-16 14:17:24 +01:00
|
|
|
}
|
2018-02-08 12:01:06 +01:00
|
|
|
|
2018-02-15 17:46:57 +01:00
|
|
|
export function onSearch({ target }) {
|
2018-02-08 12:01:06 +01:00
|
|
|
return {
|
2018-02-15 17:46:57 +01:00
|
|
|
type: ON_SEARCH,
|
|
|
|
value: target.value,
|
2018-02-08 12:01:06 +01:00
|
|
|
};
|
|
|
|
}
|
2018-02-23 12:21:57 +01:00
|
|
|
|
2018-03-06 09:31:44 +01:00
|
|
|
export function setLoading() {
|
|
|
|
return {
|
|
|
|
type: SET_LOADING,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-02-23 12:21:57 +01:00
|
|
|
export function setParams(params) {
|
|
|
|
return {
|
|
|
|
type: SET_PARAMS,
|
|
|
|
params,
|
|
|
|
};
|
|
|
|
}
|
2018-02-23 15:28:01 +01:00
|
|
|
|
|
|
|
export function onSearchSuccess(data) {
|
|
|
|
return {
|
|
|
|
type: ON_SEARCH_SUCCESS,
|
|
|
|
data,
|
|
|
|
};
|
|
|
|
}
|
2018-03-06 09:31:44 +01:00
|
|
|
|
|
|
|
export function unsetLoading() {
|
|
|
|
return {
|
|
|
|
type: UNSET_LOADING,
|
|
|
|
};
|
|
|
|
}
|