2019-06-06 23:17:33 +02:00
|
|
|
import * as ActionTypes from '../../../constants';
|
|
|
|
|
|
|
|
export const DIRECTION = {
|
|
|
|
ASC: 'ASCENDING',
|
|
|
|
DESC: 'DESCENDING'
|
|
|
|
};
|
|
|
|
|
|
|
|
export function setSorting(field, direction) {
|
|
|
|
return {
|
|
|
|
type: ActionTypes.SET_SORTING,
|
|
|
|
payload: {
|
|
|
|
field,
|
|
|
|
direction
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function resetSorting() {
|
|
|
|
return setSorting('createdAt', DIRECTION.DESC);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function toggleDirectionForField(field) {
|
|
|
|
return {
|
|
|
|
type: ActionTypes.TOGGLE_DIRECTION,
|
|
|
|
field
|
|
|
|
};
|
|
|
|
}
|
2019-08-21 20:08:08 +02:00
|
|
|
|
2019-11-10 21:39:22 +01:00
|
|
|
export function setSearchTerm(scope, searchTerm) {
|
2019-08-21 20:08:08 +02:00
|
|
|
return {
|
|
|
|
type: ActionTypes.SET_SEARCH_TERM,
|
2019-11-10 21:39:22 +01:00
|
|
|
query: searchTerm,
|
|
|
|
scope,
|
2019-08-21 20:08:08 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-11-10 21:39:22 +01:00
|
|
|
export function resetSearchTerm(scope) {
|
|
|
|
return setSearchTerm(scope, '');
|
2019-08-21 20:08:08 +02:00
|
|
|
}
|