diff --git a/components/quests/questCategory.tsx b/components/quests/questCategory.tsx index ea4d934d..c8c8f306 100644 --- a/components/quests/questCategory.tsx +++ b/components/quests/questCategory.tsx @@ -20,7 +20,7 @@ const QuestCategory: FunctionComponent = ({

{category.name} Quest

- {category.questNumber} quest{category.questNumber > 1 ? "s" : ""} + {category.questNumber} quest{category.questNumber > 1 ? "s" : null}

diff --git a/components/quests/questCategoryDetails.tsx b/components/quests/questCategoryDetails.tsx index c7245a75..f6a0dec2 100644 --- a/components/quests/questCategoryDetails.tsx +++ b/components/quests/questCategoryDetails.tsx @@ -19,7 +19,7 @@ const QuestCategoryDetails: FunctionComponent = ({ quests, setShowMenu, }) => { - const [menu, setMenu] = useState(null); + const [selectedIndex, setSelectedIndex] = useState(null); useEffect(() => { const documentBody = document.querySelector("body"); @@ -35,33 +35,29 @@ const QuestCategoryDetails: FunctionComponent = ({ }, []); return ( - - <> -

Onboarding quests

-
- {quests.map((quest) => ( - - setMenu( - setMenu(null)} - /> - ) - } - imgSrc={quest.img_card} - issuer={{ - name: quest.issuer, - logoFavicon: quest.logo, - }} - reward={quest.rewards_title} - /> - ))} -
- {menu} - + setShowMenu(false)}> +

Onboarding quests

+
+ {quests.map((quest, index) => ( + setSelectedIndex(index)} + imgSrc={quest.img_card} + issuer={{ + name: quest.issuer, + logoFavicon: quest.logo, + }} + reward={quest.rewards_title} + /> + ))} +
+ {selectedIndex !== null && ( + setSelectedIndex(null)} + /> + )}
); }; diff --git a/components/quests/questDetails.tsx b/components/quests/questDetails.tsx index d7964f35..47e6023e 100644 --- a/components/quests/questDetails.tsx +++ b/components/quests/questDetails.tsx @@ -5,12 +5,12 @@ import QuestMenu from "./questMenu"; type QuestDetailsProps = { quest: QuestDocument; - setShowMenu: (showMenu: boolean) => void; + close: () => void; }; const QuestDetails: FunctionComponent = ({ quest, - setShowMenu, + close, }) => { useEffect(() => { const documentBody = document.querySelector("body"); @@ -26,10 +26,8 @@ const QuestDetails: FunctionComponent = ({ }, []); return ( - - <> - - + + ); }; diff --git a/components/quests/questMenu.tsx b/components/quests/questMenu.tsx index 52d0cd21..e382f128 100644 --- a/components/quests/questMenu.tsx +++ b/components/quests/questMenu.tsx @@ -22,22 +22,7 @@ import TasksSkeleton from "../../components/skeletons/tasksSkeleton"; import { generateCodeChallenge } from "../../utils/codeChallenge"; import Timer from "../../components/quests/timer"; import Nfts from "./nfts"; - -const splitByNftContract = ( - rewards: EligibleReward[] -): Record => { - return rewards.reduce( - (acc: Record, reward: EligibleReward) => { - if (!acc[reward.nft_contract]) { - acc[reward.nft_contract] = []; - } - - acc[reward.nft_contract].push(reward); - return acc; - }, - {} - ); -}; +import { splitByNftContract } from "../../utils/rewards"; type QuestMenuProps = { quest: QuestDocument; diff --git a/components/quests/screenLayout.tsx b/components/quests/screenLayout.tsx index 20b44104..7ed01686 100644 --- a/components/quests/screenLayout.tsx +++ b/components/quests/screenLayout.tsx @@ -6,12 +6,12 @@ import Blur from "../shapes/blur"; type ScreenLayoutProps = { children: ReactNode; - setShowMenu: (showMenu: boolean) => void; + close: () => void; }; const ScreenLayout: FunctionComponent = ({ children, - setShowMenu, + close, }) => { return (
@@ -19,7 +19,7 @@ const ScreenLayout: FunctionComponent = ({
- setShowMenu(false)} /> + close()} />
{children}
diff --git a/utils/rewards.ts b/utils/rewards.ts new file mode 100644 index 00000000..84000469 --- /dev/null +++ b/utils/rewards.ts @@ -0,0 +1,15 @@ +export const splitByNftContract = ( + rewards: EligibleReward[] +): Record => { + return rewards.reduce( + (acc: Record, reward: EligibleReward) => { + if (!acc[reward.nft_contract]) { + acc[reward.nft_contract] = []; + } + + acc[reward.nft_contract].push(reward); + return acc; + }, + {} + ); +};