1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { searchBarActions, SearchBarActions } from '~/store/search-bar/search-bar-actions';
6 import { GroupContentsResource } from '~/services/groups-service/groups-service';
7 import { SearchBarAdvanceFormData } from '~/models/search-bar';
12 searchResults: GroupContentsResource[];
14 savedQueries: SearchBarAdvanceFormData[];
17 export enum SearchView {
19 ADVANCED = 'advanced',
20 AUTOCOMPLETE = 'autocomplete'
23 const initialState: SearchBar = {
24 currentView: SearchView.BASIC,
31 export const searchBarReducer = (state = initialState, action: SearchBarActions): SearchBar =>
32 searchBarActions.match(action, {
33 SET_CURRENT_VIEW: currentView => ({ ...state, currentView }),
34 OPEN_SEARCH_VIEW: () => ({ ...state, open: true }),
35 CLOSE_SEARCH_VIEW: () => ({ ...state, open: false }),
36 SET_SEARCH_RESULTS: (searchResults) => ({ ...state, searchResults }),
37 SET_SEARCH_VALUE: (searchValue) => ({ ...state, searchValue }),
38 SET_SAVED_QUERIES: savedQueries => ({ ...state, savedQueries }),
39 UPDATE_SAVED_QUERY: searchQuery => ({ ...state, savedQueries: searchQuery }),