diff options
Diffstat (limited to 'src/components')
-rw-r--r-- | src/components/search/SearchResultCell.tsx | 3 | ||||
-rw-r--r-- | src/components/search/SearchResultList.tsx | 24 |
2 files changed, 17 insertions, 10 deletions
diff --git a/src/components/search/SearchResultCell.tsx b/src/components/search/SearchResultCell.tsx index e0351d96..5cba6d2f 100644 --- a/src/components/search/SearchResultCell.tsx +++ b/src/components/search/SearchResultCell.tsx @@ -23,11 +23,13 @@ import { } from '../../utils/users'; interface SearchResults { + type: 'badges' | 'categories' | 'users'; profileData: ProfilePreviewType; loggedInUser: UserType; } const SearchResultsCell: React.FC<SearchResults> = ({ + type, profileData: { id, name, @@ -112,6 +114,7 @@ const SearchResultsCell: React.FC<SearchResults> = ({ 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 41c8c8b2..939bfa2b 100644 --- a/src/components/search/SearchResultList.tsx +++ b/src/components/search/SearchResultList.tsx @@ -25,14 +25,15 @@ const SearchResultList: React.FC<SearchResultsProps> = ({ results, keyboardVisible, }) => { - const [showSection, setShowSection] = useState(true); const [showEmptyView, setshowEmptyView] = useState(false); const {user: loggedInUser} = useSelector((state: RootState) => state.user); useEffect(() => { if (results && results.length > 0) { setshowEmptyView( - results[0].data.length === 0 && results[1].data.length === 0, + results[0].data.length === 0 && + results[1].data.length === 0 && + results[2].data.length === 0, ); } }, [results]); @@ -53,15 +54,18 @@ const SearchResultList: React.FC<SearchResultsProps> = ({ contentContainerStyle={{paddingBottom: SCREEN_HEIGHT * 0.1}} sections={results} keyExtractor={(item, index) => item.id + index} - renderItem={({item}) => ( - <SearchResultsCell profileData={item} loggedInUser={loggedInUser} /> - )} - renderSectionHeader={({section: {title, data}}) => { - if (title === 'categories' && data.length === 0) { - setShowSection(false); - } - return sectionHeader(title !== 'categories' && showSection); + renderItem={({section, item}) => { + return ( + <SearchResultsCell + type={section.title} + profileData={item} + loggedInUser={loggedInUser} + /> + ); }} + renderSectionHeader={({section: {data}}) => + sectionHeader(data.length !== 0) + } /> )} </View> |