diff options
Diffstat (limited to 'src/components/search')
| -rw-r--r-- | src/components/search/SearchBar.tsx | 21 | ||||
| -rw-r--r-- | src/components/search/SearchResultCell.tsx | 8 |
2 files changed, 12 insertions, 17 deletions
diff --git a/src/components/search/SearchBar.tsx b/src/components/search/SearchBar.tsx index 5008ff53..4824b56f 100644 --- a/src/components/search/SearchBar.tsx +++ b/src/components/search/SearchBar.tsx @@ -1,22 +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 {Universities} from '../../types'; +import {getSearchSuggestions, SCREEN_HEIGHT} from '../../utils'; const AnimatedIcon = Animated.createAnimatedComponent(Icon); @@ -40,9 +39,7 @@ const SearchBar: React.FC<SearchBarProps> = ({ e.preventDefault(); Keyboard.dismiss(); }; - const {profile: {university = Universities.cornell} = {}} = useSelector( - (state: RootState) => state.user, - ); + 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(university); diff --git a/src/components/search/SearchResultCell.tsx b/src/components/search/SearchResultCell.tsx index 6ebe19a6..5a6ea110 100644 --- a/src/components/search/SearchResultCell.tsx +++ b/src/components/search/SearchResultCell.tsx @@ -10,7 +10,7 @@ import { CategoryPreviewType, ProfilePreviewType, ScreenType, - Universities, + UniversityType, UserType, } from '../../types'; import { @@ -46,9 +46,7 @@ const SearchResultsCell: React.FC<SearchResults> = ({ }) => { const [avatar, setAvatar] = useState<string | undefined>(undefined); - const {profile: {university = Universities.cornell} = {}} = useSelector( - (state: RootState) => state.user, - ); + const {university} = useSelector((state: RootState) => state.user.profile); useEffect(() => { (async () => { @@ -157,7 +155,7 @@ const SearchResultsCell: React.FC<SearchResults> = ({ <Image resizeMode="contain" source={ - category in Universities + category in UniversityType ? getUniversityBadge(university, 'Search') : searchIcon() } |
