diff --git a/src/components/practice/community.jsx b/src/components/practice/community.jsx index 339ed5b6..14689a20 100644 --- a/src/components/practice/community.jsx +++ b/src/components/practice/community.jsx @@ -3,7 +3,8 @@ import ChallengeCard from '../profile/ChallengeCard'; import { Fragment } from 'react'; import { Listbox, Transition } from '@headlessui/react'; import { CheckIcon, ChevronUpDownIcon } from '@heroicons/react/24/solid'; - +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { faFolderOpen } from '@fortawesome/free-solid-svg-icons'; function getCategoryIcon(category) { switch (category.toLowerCase()) { case 'forensics': @@ -290,39 +291,48 @@ export function Community({ challenges }) {
- {challenges && (results.length > 0 ? results : challenges) - .filter((challenge) => { - if ( - difficulty.toLowerCase() !== 'all' && - challenge.difficulty.toLowerCase() !== difficulty.toLowerCase() - ) { - return false; - } - if ( - filter !== '' && - challenge.category.includes(filter.toLowerCase()) - ) { + {results.length > 0 ? ( + results + .filter((challenge) => { + if ( + difficulty.toLowerCase() !== 'all' && + challenge.difficulty.toLowerCase() !== difficulty.toLowerCase() + ) { + return false; + } + if ( + filter !== '' && + challenge.category.includes(filter.toLowerCase()) + ) { + return true; + } + if ( + filter !== '' && + !( + challenge.title + .toLowerCase() + .includes(filter.toLowerCase()) || + challenge.content + .toLowerCase() + .includes(filter.toLowerCase()) + ) + ) { + return false; + } return true; - } - if ( - filter !== '' && - !( - challenge.title - .toLowerCase() - .includes(filter.toLowerCase()) || - challenge.content - .toLowerCase() - .includes(filter.toLowerCase()) - ) - ) { - return false; - } - return true; - }) - .map((challenge) => ( - - )) - } + }) + .map((challenge) => ( + + )) + ) : ( + // kinda hacky but it works + challenges.length != 0 && ( +
+ +

No challenges found with the current filters. Try changing the filters or search for a different challenge.

+
+ ) + )}