From bb670832a2ff330ecc3e7e27754fb62faf3e05fe Mon Sep 17 00:00:00 2001 From: Som401 Date: Sun, 3 Mar 2024 11:41:47 +0100 Subject: [PATCH 1/3] Combine all the empty data fields --- src/components/Explore/Explore.jsx | 113 +++++++++++++++++++---------- 1 file changed, 74 insertions(+), 39 deletions(-) diff --git a/src/components/Explore/Explore.jsx b/src/components/Explore/Explore.jsx index a3bb1781..5602bef0 100644 --- a/src/components/Explore/Explore.jsx +++ b/src/components/Explore/Explore.jsx @@ -22,6 +22,7 @@ import Sidebar from "../Feeds/SocialSidebar/Sidebar"; import { FilterButton } from "../Feeds/FeedsElements"; import { HintIcon } from "../WebSecurity/Common/HintElements"; import { FaAngleDown, FaAngleUp } from "react-icons/fa"; +import NotFound from "../../NotFound"; const FilterContainer = styled.div``; @@ -235,45 +236,79 @@ const Explore = () => { - {selectedType === "all" || selectedType === "users" ? ( - - ) : null} - - {selectedType === "all" || selectedType === "feeds" ? ( - - ) : null} - - {selectedType === "all" || selectedType === "blogs" ? ( - - ) : null} - - {/* {selectedType === "all" || selectedType === "forum" ? ( */} - {/* */} - {/* ) : null} */} - - {selectedType === "all" || selectedType === "ctf" ? ( - - ) : null} + {selectedType === "all" ? ( + !filteredUsers.length && + !filteredFeeds.length && + !filteredBlogs.length && + !filteredCtf.length ? ( + + ) : ( + <> + + + + + + ) + ) : ( + <> + {selectedType === "users" ? ( + + ) : null} + + {selectedType === "feeds" ? ( + + ) : null} + + {selectedType === "blogs" ? ( + + ) : null} + + {selectedType === "ctf" ? ( + + ) : null} + + )} From 02dd88c211f2abb80b6ebded1f0eff6c63e266b9 Mon Sep 17 00:00:00 2001 From: Som401 Date: Tue, 5 Mar 2024 11:13:55 +0000 Subject: [PATCH 2/3] add renderNotFoundComponents function --- src/components/Explore/Explore.jsx | 43 +++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/src/components/Explore/Explore.jsx b/src/components/Explore/Explore.jsx index 5602bef0..6127b111 100644 --- a/src/components/Explore/Explore.jsx +++ b/src/components/Explore/Explore.jsx @@ -211,6 +211,29 @@ const Explore = () => { { value: followers, label: "Followers" }, ]; + const renderNotFoundComponents = () => { + const dataTypes = ["Users", "Feeds", "Blogs", "Ctfs"]; + const filteredData = { + Users: filteredUsers, + Feeds: filteredFeeds, + Blogs: filteredBlogs, + Ctfs: filteredCtf, + }; + const missingDataTypes = dataTypes.filter((type) => !filteredData[type].length); + + if (missingDataTypes.length === dataTypes.length) { + return ; + } else if (missingDataTypes.length) { + const lastType = missingDataTypes.pop(); + const missingDataTypesString = missingDataTypes.length + ? `${missingDataTypes.join(", ")} and ${lastType}` + : lastType; + return ; + } + + return null; + }; + if (isApiLoading || isCtfLoading) return ; if (!isApiWorking) return ; @@ -237,39 +260,41 @@ const Explore = () => { {selectedType === "all" ? ( - !filteredUsers.length && - !filteredFeeds.length && - !filteredBlogs.length && - !filteredCtf.length ? ( - - ) : ( - <> + <> + {filteredUsers.length ? ( + ) : null} + {filteredFeeds.length ? ( + ) : null} + {filteredBlogs.length ? ( + ) : null} + {filteredCtf.length ? ( - - ) + ) : null} + {renderNotFoundComponents()} + ) : ( <> {selectedType === "users" ? ( From 2d8030807128c775d9e30a614ddcae0b7efefae8 Mon Sep 17 00:00:00 2001 From: Som401 Date: Tue, 5 Mar 2024 11:23:34 +0000 Subject: [PATCH 3/3] small fix --- src/components/Explore/Explore.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Explore/Explore.jsx b/src/components/Explore/Explore.jsx index 6127b111..a782d41b 100644 --- a/src/components/Explore/Explore.jsx +++ b/src/components/Explore/Explore.jsx @@ -228,7 +228,7 @@ const Explore = () => { const missingDataTypesString = missingDataTypes.length ? `${missingDataTypes.join(", ")} and ${lastType}` : lastType; - return ; + return ; } return null;