aboutsummaryrefslogtreecommitdiff
path: root/src/components/search
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/search')
-rw-r--r--src/components/search/SearchBar.tsx8
-rw-r--r--src/components/search/SearchResultCell.tsx19
2 files changed, 20 insertions, 7 deletions
diff --git a/src/components/search/SearchBar.tsx b/src/components/search/SearchBar.tsx
index 62bda77e..5008ff53 100644
--- a/src/components/search/SearchBar.tsx
+++ b/src/components/search/SearchBar.tsx
@@ -14,6 +14,9 @@ import Animated, {interpolate} from 'react-native-reanimated';
import Icon from 'react-native-vector-icons/Feather';
import {normalize} from 'react-native-elements';
import {SCREEN_HEIGHT, getSearchSuggestions} from '../../utils';
+import {useSelector} from 'react-redux';
+import {RootState} from '../../store/rootReducer';
+import {Universities} from '../../types';
const AnimatedIcon = Animated.createAnimatedComponent(Icon);
@@ -37,9 +40,12 @@ const SearchBar: React.FC<SearchBarProps> = ({
e.preventDefault();
Keyboard.dismiss();
};
+ const {profile: {university = Universities.cornell} = {}} = useSelector(
+ (state: RootState) => state.user,
+ );
const DEFAULT_PLACEHOLDER: string = 'Search';
// the list of suggestions to cycle through. TODO: get this from the backend
- const SEARCH_SUGGESTIONS: string[] = getSearchSuggestions();
+ const SEARCH_SUGGESTIONS: string[] = getSearchSuggestions(university);
/*
* index & id of current placeholder, used in selecting next placeholder. -1
* indicates DEFAULT_PLACEHOLDER. TODO: make it appear more random by tracking
diff --git a/src/components/search/SearchResultCell.tsx b/src/components/search/SearchResultCell.tsx
index 4484bcd3..6ebe19a6 100644
--- a/src/components/search/SearchResultCell.tsx
+++ b/src/components/search/SearchResultCell.tsx
@@ -2,7 +2,7 @@ import {useNavigation} from '@react-navigation/native';
import React, {useEffect, useState} from 'react';
import {Alert, Image, StyleSheet, Text, View} from 'react-native';
import {TouchableOpacity} from 'react-native-gesture-handler';
-import {useDispatch, useStore} from 'react-redux';
+import {useDispatch, useSelector, useStore} from 'react-redux';
import {ERROR_UNABLE_TO_VIEW_PROFILE} from '../../constants/strings';
import {loadImageFromURL} from '../../services';
import {RootState} from '../../store/rootReducer';
@@ -10,11 +10,13 @@ import {
CategoryPreviewType,
ProfilePreviewType,
ScreenType,
+ Universities,
UserType,
} from '../../types';
import {
addCategoryToRecentlySearched,
addUserToRecentlySearched,
+ getUniversityBadge,
normalize,
SCREEN_WIDTH,
} from '../../utils';
@@ -43,6 +45,11 @@ const SearchResultsCell: React.FC<SearchResults> = ({
loggedInUser,
}) => {
const [avatar, setAvatar] = useState<string | undefined>(undefined);
+
+ const {profile: {university = Universities.cornell} = {}} = useSelector(
+ (state: RootState) => state.user,
+ );
+
useEffect(() => {
(async () => {
if (thumbnail_url !== undefined) {
@@ -143,17 +150,17 @@ const SearchResultsCell: React.FC<SearchResults> = ({
return require('../../assets/images/search.png');
};
- const universityIcon = () => {
- return require('../../assets/images/bwbadges.png');
- };
-
const categoryCell = () => {
return (
<TouchableOpacity style={styles.cellContainer} onPress={onPressCategory}>
<View style={[styles.imageContainer, styles.categoryBackground]}>
<Image
resizeMode="contain"
- source={category === 'Brown' ? universityIcon() : searchIcon()} //TODO: Update for Cornell
+ source={
+ category in Universities
+ ? getUniversityBadge(university, 'Search')
+ : searchIcon()
+ }
style={styles.categoryImage}
/>
</View>