From 594de4668248bac9b744e6882329183c95ac339c Mon Sep 17 00:00:00 2001 From: Leon Jiang <35908040+leonyjiang@users.noreply.github.com> Date: Wed, 10 Mar 2021 18:15:26 -0500 Subject: Add utils, fix ordering of recent searches --- src/components/search/SearchResultCell.tsx | 4 ++-- src/components/search/SearchResults.tsx | 34 ++++++++++++++++++------------ 2 files changed, 22 insertions(+), 16 deletions(-) (limited to 'src/components') diff --git a/src/components/search/SearchResultCell.tsx b/src/components/search/SearchResultCell.tsx index 5cba6d2f..f274bfb9 100644 --- a/src/components/search/SearchResultCell.tsx +++ b/src/components/search/SearchResultCell.tsx @@ -14,11 +14,11 @@ import { } from '../../types'; import {normalize, SCREEN_WIDTH} from '../../utils'; import { - addUserToRecentlyViewed, checkIfUserIsBlocked, defaultUserProfile, fetchUserX, userXInStore, + addUserToRecentlySearched, addCategoryToRecentlySearched, } from '../../utils/users'; @@ -74,7 +74,7 @@ const SearchResultsCell: React.FC = ({ return; } - addUserToRecentlyViewed({ + addUserToRecentlySearched({ id, first_name, last_name, diff --git a/src/components/search/SearchResults.tsx b/src/components/search/SearchResults.tsx index 277b3454..ef518d8b 100644 --- a/src/components/search/SearchResults.tsx +++ b/src/components/search/SearchResults.tsx @@ -23,20 +23,26 @@ const SearchResults: React.FC = ({results, categories}) => { const {user: loggedInUser} = useSelector((state: RootState) => state.user); return ( - {categories.map((category: CategoryPreviewType) => ( - - ))} - {results.map((profile: ProfilePreviewType) => ( - - ))} + {categories + .slice(0) + .reverse() + .map((category: CategoryPreviewType) => ( + + ))} + {results + .slice(0) + .reverse() + .map((profile: ProfilePreviewType) => ( + + ))} ); }; -- cgit v1.2.3-70-g09d2