From 7cbe5a7e570412e7d17a1a9208a043e6c76d2a10 Mon Sep 17 00:00:00 2001 From: Adenekan Wonderful <adenekanwonderful41@gmail.com> Date: Thu, 5 Jan 2023 03:58:35 +0100 Subject: [PATCH] (chore): added constants for recent searches --- src/components/stem/index.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/stem/index.tsx b/src/components/stem/index.tsx index 8f43286..1a3114d 100644 --- a/src/components/stem/index.tsx +++ b/src/components/stem/index.tsx @@ -326,7 +326,10 @@ const RecentSearch: React.FC<{ removeRecentSearch: (search: string) => void; setInputValue?: (value: string) => void; }> = memo(({ recents: recentSearch, removeRecentSearch, setInputValue }) => { + const RECENT_SEARCH_NUMBER = 5; + const [isShowMore, setIsShowMore] = useState(false); + return ( <> {!isEmpty(recentSearch) && ( @@ -334,7 +337,7 @@ const RecentSearch: React.FC<{ <p className={styles.header}>Recent Search</p> <div className={styles.recentSearch}> {recentSearch - .slice(0, isShowMore ? recentSearch.length : 5) + .slice(0, isShowMore ? recentSearch.length : RECENT_SEARCH_NUMBER) ?.map((search, index) => ( <div className={styles.recentCell} key={`${search}:${index}`}> <Icon @@ -401,7 +404,8 @@ const RecentSearch: React.FC<{ > {!isShowMore ? ( <> - Show <b>{recentSearch.length - 5}</b> more... + Show <b>{recentSearch.length - RECENT_SEARCH_NUMBER}</b>{' '} + more... </> ) : ( <>Show less</>