diff options
| author | Ivan Chen <ivan@tagg.id> | 2021-03-08 19:54:42 -0500 |
|---|---|---|
| committer | Ivan Chen <ivan@tagg.id> | 2021-03-08 19:54:42 -0500 |
| commit | f899dc058f90813c5ae71e55407a11e6ca13e1ed (patch) | |
| tree | 84c93e869fab6d434d6709dc1d471c6e588c4e4e /src/components/search/SearchResults.tsx | |
| parent | 8837ea74dbff9cf455cd7cb092767e51de3900f8 (diff) | |
| parent | d77f43663fbe409b011b5509bcbff3d07f8ded55 (diff) | |
Merge branch 'master' into tma684-search-for-badges
# Conflicts:
# src/components/search/SearchResultCell.tsx
# src/components/search/SearchResultList.tsx
Diffstat (limited to 'src/components/search/SearchResults.tsx')
| -rw-r--r-- | src/components/search/SearchResults.tsx | 52 |
1 files changed, 35 insertions, 17 deletions
diff --git a/src/components/search/SearchResults.tsx b/src/components/search/SearchResults.tsx index bf355220..798d3251 100644 --- a/src/components/search/SearchResults.tsx +++ b/src/components/search/SearchResults.tsx @@ -1,22 +1,33 @@ import React from 'react'; -import {ProfilePreviewType, PreviewType, ScreenType} from '../../types'; +import { + ProfilePreviewType, + PreviewType, + ScreenType, + CategoryPreviewType, +} from '../../types'; import ProfilePreview from '../profile/ProfilePreview'; import {StyleSheet, View} from 'react-native'; +import SearchResultsCell from './SearchResultCell'; +import {useSelector} from 'react-redux'; +import {RootState} from 'src/store/rootReducer'; interface SearchResultsProps { - results: Array<ProfilePreviewType>; + results: ProfilePreviewType[]; previewType: PreviewType; screenType: ScreenType; + categories: CategoryPreviewType[]; } const SearchResults: React.FC<SearchResultsProps> = ({ results, previewType, screenType, + categories, }) => { /** * Added the following swicth case to make Results on Search and Recents screen a list * Flex is love */ - var containerStyle; + const {user: loggedInUser} = useSelector((state: RootState) => state.user); + let containerStyle; switch (previewType) { case 'Search': containerStyle = styles.containerSearch; @@ -29,25 +40,32 @@ const SearchResults: React.FC<SearchResultsProps> = ({ } return ( <View style={containerStyle}> - {results && - results.map((profilePreview) => ( - <ProfilePreview - style={styles.result} - key={profilePreview.id} - {...{profilePreview}} - previewType={previewType} - screenType={screenType} - /> - ))} + {categories.map((category: CategoryPreviewType) => ( + <SearchResultsCell + key={category.name} + profileData={category} + {...{loggedInUser}} + /> + ))} + {results.map((profile: ProfilePreviewType) => ( + <SearchResultsCell + key={profile.id} + profileData={profile} + {...{loggedInUser}} + /> + ))} </View> ); }; const styles = StyleSheet.create({ - containerSearch: {flexDirection: 'column', flexWrap: 'wrap'}, - container: {flexDirection: 'row', flexWrap: 'wrap'}, - result: { - marginVertical: 10, + containerSearch: { + flexDirection: 'column', + flexWrap: 'wrap', + }, + container: { + flexDirection: 'row', + flexWrap: 'wrap', }, }); |
