From d514b5d5eb0f3581d67ae45c74c40109c5048ec7 Mon Sep 17 00:00:00 2001 From: Raul-Cristian Kele Date: Tue, 26 Sep 2023 15:02:23 +0300 Subject: [PATCH] patch: update nodata display on homepage Signed-off-by: Raul-Cristian Kele --- src/components/Home/Home.jsx | 135 ++++++++++++++++++----------------- 1 file changed, 70 insertions(+), 65 deletions(-) diff --git a/src/components/Home/Home.jsx b/src/components/Home/Home.jsx index 8da2eddc..83306021 100644 --- a/src/components/Home/Home.jsx +++ b/src/components/Home/Home.jsx @@ -200,11 +200,16 @@ function Home() { navigate({ pathname: `/explore`, search: createSearchParams({ [type]: value }).toString() }); }; - const renderCards = (cardArray, isLoading) => { - if (cardArray && cardArray.length < 1 && !isLoading) { - return ; - } + const isNoData = () => + !isLoading && + !isLoadingBookmarks && + !isLoadingPopular && + !isLoadingRecent && + bookmarkData.length === 0 && + popularData.length === 0 && + recentData.length === 0; + const renderCards = (cardArray) => { return ( cardArray && cardArray.map((item, index) => { @@ -232,68 +237,68 @@ function Home() { ); }; - return ( - <> - {isLoading ? ( - - ) : ( - - -
- - Most popular images - -
-
handleClickViewAll('sortby', sortByCriteria.downloads.value)}> - - View all - -
-
- {isLoadingPopular ? : renderCards(popularData, isLoadingPopular)} - {/* currently most popular will be by downloads until stars are implemented */} - -
- - Recently updated images - -
-
- handleClickViewAll('sortby', sortByCriteria.updateTime.value)} - > - View all - -
-
- {isLoadingRecent ? : renderCards(recentData, isLoadingRecent)} - {!isEmpty(bookmarkData) && ( - <> - -
- - Bookmarks - -
-
- handleClickViewAll('filter', 'IsBookmarked')} - > - View all - -
-
- {isLoadingBookmarks ? : renderCards(bookmarkData, isLoadingBookmarks)} - - )} + const renderContent = () => { + return isNoData() === true ? ( + + ) : ( + + +
+ + Most popular images + +
+
handleClickViewAll('sortby', sortByCriteria.downloads.value)}> + + View all + +
+
+ {isLoadingPopular ? : renderCards(popularData, isLoadingPopular)} + {/* currently most popular will be by downloads until stars are implemented */} + +
+ + Recently updated images + +
+
+ handleClickViewAll('sortby', sortByCriteria.updateTime.value)} + > + View all + +
- )} - - ); + {isLoadingRecent ? : renderCards(recentData, isLoadingRecent)} + {!isEmpty(bookmarkData) && ( + <> + +
+ + Bookmarks + +
+
+ handleClickViewAll('filter', 'IsBookmarked')} + > + View all + +
+
+ {isLoadingBookmarks ? : renderCards(bookmarkData, isLoadingBookmarks)} + + )} +
+ ); + }; + + return <>{isLoading ? : renderContent()}; } export default Home;