From 4a05b26c5c32980ac18c832cc4dd74c6c93922a8 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Fri, 12 Mar 2021 14:17:55 -0500 Subject: using discover/get_users, updated route params, cleaned up code --- src/components/search/SearchCategories.tsx | 25 +++++++++++++++++-------- src/components/search/SearchResultCell.tsx | 3 --- src/components/search/SearchResultList.tsx | 1 - 3 files changed, 17 insertions(+), 12 deletions(-) (limited to 'src/components/search') diff --git a/src/components/search/SearchCategories.tsx b/src/components/search/SearchCategories.tsx index f00debb5..a71befe6 100644 --- a/src/components/search/SearchCategories.tsx +++ b/src/components/search/SearchCategories.tsx @@ -2,16 +2,18 @@ import {useNavigation} from '@react-navigation/native'; import React, {useEffect, useState} from 'react'; import {StyleSheet, View} from 'react-native'; import {GradientBorderButton} from '..'; -import {getButtons} from '../../services/ExploreService'; +import {getSuggestedSearchBubbleSuggestions} from '../../services/ExploreService'; import {SearchCategoryType} from '../../types'; import {SCREEN_WIDTH} from '../../utils'; interface SearchCategoriesProps { darkStyle?: boolean; + defaultButtons?: SearchCategoryType[]; } const SearchCategories: React.FC = ({ darkStyle = false, + defaultButtons, }) => { const navigation = useNavigation(); const mtSearchCategory: (key: number) => SearchCategoryType = (key) => ({ @@ -20,18 +22,25 @@ const SearchCategories: React.FC = ({ category: '...', }); const [buttons, setButtons] = useState([ - mtSearchCategory(1), - mtSearchCategory(2), - mtSearchCategory(3), - mtSearchCategory(4), + mtSearchCategory(-1), + mtSearchCategory(-2), + mtSearchCategory(-3), + mtSearchCategory(-4), ]); + useEffect(() => { const loadButtons = async () => { - const localButtons = await getButtons(); + const localButtons = await getSuggestedSearchBubbleSuggestions(); setButtons([]); - setButtons(localButtons); + if (localButtons) { + setButtons(localButtons); + } }; - loadButtons(); + if (!defaultButtons) { + loadButtons(); + } else { + setButtons(defaultButtons); + } }, []); return ( diff --git a/src/components/search/SearchResultCell.tsx b/src/components/search/SearchResultCell.tsx index 5cba6d2f..e0351d96 100644 --- a/src/components/search/SearchResultCell.tsx +++ b/src/components/search/SearchResultCell.tsx @@ -23,13 +23,11 @@ import { } from '../../utils/users'; interface SearchResults { - type: 'badges' | 'categories' | 'users'; profileData: ProfilePreviewType; loggedInUser: UserType; } const SearchResultsCell: React.FC = ({ - type, profileData: { id, name, @@ -114,7 +112,6 @@ const SearchResultsCell: React.FC = ({ const categoryObj: CategoryPreviewType = {name, category}; addCategoryToRecentlySearched(categoryObj); navigation.navigate('DiscoverUsers', { - type, searchCategory: {id, name}, }); }; diff --git a/src/components/search/SearchResultList.tsx b/src/components/search/SearchResultList.tsx index d8cf02d9..704e4192 100644 --- a/src/components/search/SearchResultList.tsx +++ b/src/components/search/SearchResultList.tsx @@ -57,7 +57,6 @@ const SearchResultList: React.FC = ({ renderItem={({section, item}) => { return ( -- cgit v1.2.3-70-g09d2