aboutsummaryrefslogtreecommitdiff
path: root/src/components/search
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/search')
-rw-r--r--src/components/search/SearchBar.tsx21
-rw-r--r--src/components/search/SearchResultCell.tsx17
2 files changed, 23 insertions, 15 deletions
diff --git a/src/components/search/SearchBar.tsx b/src/components/search/SearchBar.tsx
index 62bda77e..4824b56f 100644
--- a/src/components/search/SearchBar.tsx
+++ b/src/components/search/SearchBar.tsx
@@ -1,19 +1,21 @@
-import React, {useState, useEffect} from 'react';
+import React, {useEffect, useState} from 'react';
import {
+ Keyboard,
+ NativeSyntheticEvent,
StyleSheet,
- TextInput,
- TouchableOpacity,
Text,
- View,
+ TextInput,
TextInputProps,
- Keyboard,
- NativeSyntheticEvent,
TextInputSubmitEditingEventData,
+ TouchableOpacity,
+ View,
} from 'react-native';
+import {normalize} from 'react-native-elements';
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 {getSearchSuggestions, SCREEN_HEIGHT} from '../../utils';
const AnimatedIcon = Animated.createAnimatedComponent(Icon);
@@ -37,9 +39,10 @@ const SearchBar: React.FC<SearchBarProps> = ({
e.preventDefault();
Keyboard.dismiss();
};
+ const {university} = useSelector((state: RootState) => state.user.profile);
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 9a8216e5..5a6ea110 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,
+ UniversityType,
UserType,
} from '../../types';
import {
addCategoryToRecentlySearched,
addUserToRecentlySearched,
+ getUniversityBadge,
normalize,
SCREEN_WIDTH,
} from '../../utils';
@@ -43,6 +45,9 @@ const SearchResultsCell: React.FC<SearchResults> = ({
loggedInUser,
}) => {
const [avatar, setAvatar] = useState<string | undefined>(undefined);
+
+ const {university} = useSelector((state: RootState) => state.user.profile);
+
useEffect(() => {
(async () => {
if (thumbnail_url !== undefined) {
@@ -143,17 +148,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()}
+ source={
+ category in UniversityType
+ ? getUniversityBadge(university, 'Search')
+ : searchIcon()
+ }
style={styles.categoryImage}
/>
</View>