109 lines
1.5 KiB
JavaScript
Raw Normal View History

/*
*
* 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,
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,
SET_LOADING,
2018-02-23 12:21:57 +01:00
SET_PARAMS,
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,
};
}
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]);
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
}
export function onSearch({ target }) {
return {
type: ON_SEARCH,
value: target.value,
};
}
2018-02-23 12:21:57 +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,
};
}
export function unsetLoading() {
return {
type: UNSET_LOADING,
};
}