From 8ce46790a8d12df6738d8ac17462ba57e2b0e6b9 Mon Sep 17 00:00:00 2001 From: ankit-thanekar007 Date: Wed, 24 Mar 2021 16:09:45 -0700 Subject: Cornell Changes --- src/components/search/SearchBar.tsx | 8 +++++++- src/components/search/SearchResultCell.tsx | 19 +++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) (limited to 'src/components/search') 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 = ({ 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 = ({ loggedInUser, }) => { const [avatar, setAvatar] = useState(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 = ({ return require('../../assets/images/search.png'); }; - const universityIcon = () => { - return require('../../assets/images/bwbadges.png'); - }; - const categoryCell = () => { return ( -- cgit v1.2.3-70-g09d2