-export const closeSearchView = () =>
- (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
- const isOpen = getState().searchBar.open;
- if(isOpen) {
- dispatch(searchBarActions.CLOSE_SEARCH_VIEW());
+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());