2016-07-08 07:20:20 -03:00
|
|
|
import { browserHistory } from 'react-router';
|
|
|
|
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:
|
|
|
|
browserHistory.push('/collections/posts');
|
|
|
|
break;
|
|
|
|
case LIST_FAQ:
|
|
|
|
browserHistory.push('/collections/faq');
|
|
|
|
break;
|
|
|
|
case HELP:
|
|
|
|
window.alert('Find Bar Help (PLACEHOLDER)\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit.');
|
|
|
|
break;
|
|
|
|
case SEARCH:
|
|
|
|
browserHistory.push('/search');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
dispatch(run(commandName, payload));
|
|
|
|
};
|
|
|
|
}
|