static-cms/src/actions/findbar.js

32 lines
887 B
JavaScript
Raw Normal View History

2016-07-15 15:05:04 -03:00
import history from '../routing/history';
2016-07-08 07:20:20 -03:00
import { SEARCH } from '../containers/FindBar';
2016-07-06 18:51:43 -03:00
export const RUN_COMMAND = 'RUN_COMMAND';
2016-07-08 07:20:20 -03:00
export const LIST_POSTS = 'LIST_POSTS';
export const LIST_FAQ = 'LIST_FAQ';
export const HELP = 'HELP';
2016-07-06 18:51:43 -03:00
2016-07-08 07:20:20 -03:00
export function run(commandName, payload) {
2016-07-07 12:04:19 -03:00
return { type: RUN_COMMAND, command: commandName, payload };
2016-07-06 18:51:43 -03:00
}
2016-07-08 07:20:20 -03:00
export function runCommand(commandName, payload) {
return (dispatch, getState) => {
switch (commandName) {
case LIST_POSTS:
2016-07-15 15:05:04 -03:00
history.push('/collections/posts');
2016-07-08 07:20:20 -03:00
break;
case LIST_FAQ:
2016-07-15 15:05:04 -03:00
history.push('/collections/faq');
2016-07-08 07:20:20 -03:00
break;
case HELP:
window.alert('Find Bar Help (PLACEHOLDER)\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit.');
break;
case SEARCH:
2016-07-15 15:05:04 -03:00
history.push('/search');
2016-07-08 07:20:20 -03:00
break;
}
dispatch(run(commandName, payload));
};
}