+export const editSavedQuery = (data: SearchBarAdvanceFormData) =>
+ (dispatch: Dispatch<any>) => {
+ dispatch(searchBarActions.SET_CURRENT_VIEW(SearchView.ADVANCED));
+ dispatch(searchBarActions.SET_SEARCH_VALUE(data.searchQuery));
+ dispatch<any>(initialize(SEARCH_BAR_ADVANCE_FORM_NAME, data));
+ };
+
+export const openSearchView = () =>
+ (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
+ const savedSearchQueries = services.searchService.getSavedQueries();
+ dispatch(searchBarActions.SET_SAVED_QUERIES(savedSearchQueries));
+ dispatch(loadRecentQueries());
+ dispatch(searchBarActions.OPEN_SEARCH_VIEW());
+ dispatch(searchBarActions.SELECT_FIRST_ITEM());
+ };
+
+export const closeSearchView = () =>
+ (dispatch: Dispatch<any>) => {
+ dispatch(searchBarActions.SET_SELECTED_ITEM(''));
+ dispatch(searchBarActions.CLOSE_SEARCH_VIEW());
+ };
+
+export const closeAdvanceView = () =>
+ (dispatch: Dispatch<any>) => {
+ dispatch(searchBarActions.SET_SEARCH_VALUE(''));
+ dispatch(searchBarActions.SET_CURRENT_VIEW(SearchView.BASIC));
+ };
+
+export const navigateToItem = (uuid: string) =>
+ (dispatch: Dispatch<any>) => {
+ dispatch(searchBarActions.SET_SELECTED_ITEM(''));
+ dispatch(searchBarActions.CLOSE_SEARCH_VIEW());
+ dispatch(navigateTo(uuid));
+ };
+
+export const changeData = (searchValue: string) =>
+ (dispatch: Dispatch, getState: () => RootState) => {
+ dispatch(searchBarActions.SET_SEARCH_VALUE(searchValue));
+ const currentView = getState().searchBar.currentView;
+ const searchValuePresent = searchValue.length > 0;
+
+ if (currentView === SearchView.ADVANCED) {
+
+ } else if (searchValuePresent) {
+ dispatch(searchBarActions.SET_CURRENT_VIEW(SearchView.AUTOCOMPLETE));
+ dispatch(searchBarActions.SET_SELECTED_ITEM(searchValue));
+ debounceStartSearch(dispatch);
+ } else {
+ dispatch(searchBarActions.SET_CURRENT_VIEW(SearchView.BASIC));
+ dispatch(searchBarActions.SET_SEARCH_RESULTS([]));
+ dispatch(searchBarActions.SELECT_FIRST_ITEM());
+ }
+ };
+
+export const submitData = (event: React.FormEvent<HTMLFormElement>) =>
+ (dispatch: Dispatch, getState: () => RootState) => {
+ event.preventDefault();
+ const searchValue = getState().searchBar.searchValue;
+ dispatch<any>(saveRecentQuery(searchValue));
+ dispatch<any>(loadRecentQueries());
+ dispatch(searchBarActions.CLOSE_SEARCH_VIEW());