Skip to content

Commit a4f1a75

Browse files
authored
fix(GlobalSearch): navigate to Venues when clicking "View All" venues (#3477)
1 parent 99ed975 commit a4f1a75

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

website/src/types/views.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export type ComponentMap = {
1111
};
1212

1313
/* layout/GlobalSearch */
14-
export type ResultType = 'VENUE' | 'MODULE' | 'SEARCH';
14+
export type SearchResultType = 'VENUE' | 'MODULE';
1515
export const VENUE_RESULT = 'VENUE';
1616
export const MODULE_RESULT = 'MODULE';
1717
export const SEARCH_RESULT = 'SEARCH';
@@ -25,7 +25,7 @@ export type SearchResult = {
2525
export type SearchItem =
2626
| { readonly type: 'VENUE'; readonly venue: Venue }
2727
| { readonly type: 'MODULE'; readonly module: ModuleCondensed }
28-
| { readonly type: 'SEARCH'; readonly result: 'MODULE' | 'VENUE'; readonly term: string };
28+
| { readonly type: 'SEARCH'; readonly result: SearchResultType; readonly term: string };
2929

3030
/* browse/ModuleFinderContainer */
3131
export type RefinementItem = { key: string; doc_count?: number; missing?: boolean };

website/src/views/layout/GlobalSearch.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { ModuleCondensed } from 'types/modules';
99
import { Venue } from 'types/venues';
1010
import {
1111
MODULE_RESULT,
12-
ResultType,
12+
SearchResultType,
1313
SEARCH_RESULT,
1414
SearchItem,
1515
SearchResult,
@@ -25,7 +25,7 @@ type Props = {
2525

2626
onSelectVenue: (venue: Venue) => void;
2727
onSelectModule: (moduleCondensed: ModuleCondensed) => void;
28-
onSearch: (resultType: ResultType, str: string) => void;
28+
onSearch: (type: SearchResultType, query: string) => void;
2929
};
3030

3131
type State = {
@@ -91,7 +91,7 @@ class GlobalSearch extends Component<Props, State> {
9191
break;
9292

9393
case SEARCH_RESULT:
94-
onSearch(item.type, item.term);
94+
onSearch(item.result, item.term);
9595
break;
9696
}
9797
}

website/src/views/layout/GlobalSearchContainer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import useMediaQuery from 'views/hooks/useMediaQuery';
1010
import GlobalSearch from 'views/layout/GlobalSearch';
1111
import { modulePage, venuePage } from 'views/routes/paths';
1212

13-
import { ResultType, SearchResult, VENUE_RESULT } from 'types/views';
13+
import { SearchResultType, SearchResult, VENUE_RESULT } from 'types/views';
1414
import { fetchVenueList } from 'actions/venueBank';
1515
import { createSearchPredicate, regexify, sortModules, tokenize } from 'utils/moduleSearch';
1616
import { breakpointUp } from 'utils/css';
@@ -42,7 +42,7 @@ const GlobalSearchContainer: FC = () => {
4242
);
4343

4444
const onSearch = useCallback(
45-
(type: ResultType, query: string) => {
45+
(type: SearchResultType, query: string) => {
4646
// TODO: Move this into a proper function
4747
const path = type === VENUE_RESULT ? '/venues' : '/courses';
4848
history.push(`${path}?q=${encodeURIComponent(query)}`);

0 commit comments

Comments
 (0)