diff --git a/app/leaderboard/page.tsx b/app/leaderboard/page.tsx index 04513a2d..39703b69 100644 --- a/app/leaderboard/page.tsx +++ b/app/leaderboard/page.tsx @@ -317,6 +317,7 @@ export default function Page() { reward={featuredQuest?.rewards_title} desc={featuredQuest?.desc} expiry={featuredQuest?.expiry_timestamp} + questId={featuredQuest?.id} />
diff --git a/app/page.tsx b/app/page.tsx index 2bf2bfe5..33b65bfd 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -36,6 +36,7 @@ export default function Page() { reward={featuredQuest?.rewards_title} desc={featuredQuest?.desc} expiry={featuredQuest?.expiry_timestamp} + questId={featuredQuest?.id} />
diff --git a/app/quest-boost/[boostId]/page.tsx b/app/quest-boost/[boostId]/page.tsx index adfd93a8..37e159e0 100644 --- a/app/quest-boost/[boostId]/page.tsx +++ b/app/quest-boost/[boostId]/page.tsx @@ -2,6 +2,7 @@ import React, { useCallback, useEffect, useMemo, useState } from "react"; import styles from "@styles/questboost.module.css"; +import questStyles from "@styles/quests.module.css"; import { getBoostById, getQuestParticipants, @@ -141,8 +142,8 @@ export default function Page({ params }: BoostQuestPageProps) {

Reward:

-
-

+

+

{boost?.amount} {getTokenName(boost?.token ?? "")}

diff --git a/app/quest/[questPage]/quest.tsx b/app/quest/[questPage]/quest.tsx index ddc753db..a10dbb28 100644 --- a/app/quest/[questPage]/quest.tsx +++ b/app/quest/[questPage]/quest.tsx @@ -8,7 +8,6 @@ import { useRouter } from "next/navigation"; import { QueryError, QuestDocument } from "../../../types/backTypes"; import RewardSkeleton from "@components/skeletons/rewardSkeleton"; import ErrorScreen from "@components/UI/screens/errorScreen"; -import NftIssuer from "@components/quests/nftIssuer"; import BackButton from "@components/UI/backButton"; import useHasRootDomain from "@hooks/useHasRootDomain"; import { useAccount } from "@starknet-react/core"; diff --git a/components/UI/featured_banner/featuredQuest.tsx b/components/UI/featured_banner/featuredQuest.tsx index 7b103b70..ee17bf9b 100644 --- a/components/UI/featured_banner/featuredQuest.tsx +++ b/components/UI/featured_banner/featuredQuest.tsx @@ -5,6 +5,7 @@ import { useMediaQuery } from "@mui/material"; import FeaturedQuestSkeleton from "@components/skeletons/featuredQuestSkeleton"; import Timer from "@components/quests/timer"; import { CDNImg } from "@components/cdn/image"; +import BoostReward from "@components/quests/boostReward"; type FeaturedQuestProps = { onClick?: () => void; @@ -15,6 +16,7 @@ type FeaturedQuestProps = { desc?: string; expiry: string | null | undefined; heading: string; + questId?: number; }; const FeaturedQuest: FunctionComponent = ({ @@ -26,6 +28,7 @@ const FeaturedQuest: FunctionComponent = ({ desc, expiry, heading, + questId, }) => { const isSmallScreen = useMediaQuery("(max-width: 1024px)"); @@ -35,13 +38,18 @@ const FeaturedQuest: FunctionComponent = ({

{heading}

{title}

{desc}

-
- -

{reward}

+
+ {issuer?.name || issuer?.logoFavicon ? ( +
+ +

{reward}

+
+ ) : null} + {questId ? : null}
diff --git a/components/quest-boost/boostCard.tsx b/components/quest-boost/boostCard.tsx index 652f3cc8..9dbcbdb6 100644 --- a/components/quest-boost/boostCard.tsx +++ b/components/quest-boost/boostCard.tsx @@ -1,5 +1,6 @@ import React, { FunctionComponent, useEffect, useMemo, useState } from "react"; import styles from "@styles/questboost.module.css"; +import questStyles from "@styles/quests.module.css"; import Cardstyles from "@styles/components/card.module.css"; import Link from "next/link"; import UnavailableIcon from "@components/UI/iconsComponents/icons/unavailableIcon"; @@ -87,10 +88,12 @@ const BoostCard: FunctionComponent = ({ {boost?.quests.length} quest{boost.quests.length > 1 ? "s" : ""}

{!hasUserCompletedBoost && boost.expiry > Date.now() ? ( -
-

{boost?.amount}

- -
+ <> +
+

{boost?.amount}

+ +
+ ) : (
diff --git a/components/quests/boostReward.tsx b/components/quests/boostReward.tsx new file mode 100644 index 00000000..c0acc30f --- /dev/null +++ b/components/quests/boostReward.tsx @@ -0,0 +1,61 @@ +import React, { + FunctionComponent, + useCallback, + useContext, + useEffect, + useState, +} from "react"; +import { getBoosts } from "@services/apiService"; +import TokenSymbol from "@components/quest-boost/TokenSymbol"; +import { QuestsContext } from "@context/QuestsProvider"; +import styles from "../../styles/quests.module.css"; + +type BoostRewardProps = { + questId: number; +}; + +const BoostReward: FunctionComponent = ({ questId }) => { + const { boostedQuests } = useContext(QuestsContext); + const [boost, setBoost] = useState(); + const [isQuestBoosted, setIsQuestBoosted] = useState(false); + const checkIfBoostedQuest = useCallback(async () => { + if (!boostedQuests) return; + if (boostedQuests.length > 0 && boostedQuests.includes(questId)) + setIsQuestBoosted(true); + }, []); + + const fetchBoosts = useCallback(async (id: string) => { + try { + const response = await getBoosts(); + if (!response) return; + const boost = response.find((b: Boost) => + b.quests.includes(parseInt(id)) + ); + if (!boost) return; + setBoost(boost); + } catch (err) { + console.log("Error while fetching boost by id", err); + } + }, []); + + useEffect(() => { + if (!isQuestBoosted) return; + fetchBoosts(questId.toString()); + }, [isQuestBoosted, questId]); + + useEffect(() => { + checkIfBoostedQuest(); + }, []); + return ( + <> + {boost && isQuestBoosted ? ( +
+ +

{boost?.amount}

+
+ ) : null} + + ); +}; + +export default BoostReward; diff --git a/components/quests/quest.tsx b/components/quests/quest.tsx index f9d89762..f803154e 100644 --- a/components/quests/quest.tsx +++ b/components/quests/quest.tsx @@ -1,10 +1,4 @@ -import React, { - FunctionComponent, - useCallback, - useEffect, - useMemo, - useState, -} from "react"; +import React, { FunctionComponent, useMemo } from "react"; import { useContext } from "react"; import { QuestsContext } from "@context/QuestsProvider"; import CheckIcon from "@components/UI/iconsComponents/icons/checkIcon"; @@ -12,10 +6,7 @@ import UnavailableIcon from "@components/UI/iconsComponents/icons/unavailableIco import styles from "@styles/quests.module.css"; import { CDNImg } from "@components/cdn/image"; import QuestCard from "./questCard"; -import { getBoosts } from "@services/apiService"; -import TokenSymbol from "@components/quest-boost/TokenSymbol"; -import { TOKEN_DECIMAL_MAP } from "@utils/constants"; -import { getTokenName } from "@utils/tokenService"; +import BoostReward from "./boostReward"; type QuestProps = { onClick: () => void; @@ -36,42 +27,11 @@ const Quest: FunctionComponent = ({ id, expired, }) => { - const { completedQuestIds, boostedQuests } = useContext(QuestsContext); + const { completedQuestIds } = useContext(QuestsContext); const isCompleted = useMemo( () => completedQuestIds.includes(id), [id, completedQuestIds] ); - const [boost, setBoost] = useState(); - const [isQuestBoosted, setIsQuestBoosted] = useState(false); - - const checkIfBoostedQuest = useCallback(async () => { - if (!boostedQuests) return; - if (boostedQuests.length > 0 && boostedQuests.includes(id)) - setIsQuestBoosted(true); - }, []); - - const fetchBoosts = useCallback(async (id: string) => { - try { - const response = await getBoosts(); - if (!response) return; - const boost = response.find((b: Boost) => - b.quests.includes(parseInt(id)) - ); - if (!boost) return; - setBoost(boost); - } catch (err) { - console.log("Error while fetching boost by id", err); - } - }, []); - - useEffect(() => { - if (!isQuestBoosted) return; - fetchBoosts(id.toString()); - }, [isQuestBoosted, id]); - - useEffect(() => { - checkIfBoostedQuest(); - }, []); return ( = ({ >

{issuer.name}

-
+
{isCompleted ? ( <> @@ -106,15 +66,7 @@ const Quest: FunctionComponent = ({ )}
- {boost && isQuestBoosted ? ( -
- -

{boost?.amount}

-
- ) : null} +
); diff --git a/components/quests/reward.tsx b/components/quests/reward.tsx index 86922ae1..3b7a32c3 100644 --- a/components/quests/reward.tsx +++ b/components/quests/reward.tsx @@ -8,14 +8,12 @@ import Lottie from "lottie-react"; import verifiedLottie from "@public/visuals/verifiedLottie.json"; import { Call } from "starknet"; import { useNotificationManager } from "@hooks/useNotificationManager"; -import { - NotificationType, - TransactionType, -} from "@constants/notifications"; +import { NotificationType, TransactionType } from "@constants/notifications"; import { QuestDocument } from "types/backTypes"; import RewardModal from "./rewardModal"; import rewardStyles from "@styles/components/quests/modal.module.css"; import { CDNImg } from "@components/cdn/image"; +import BoostReward from "./boostReward"; type RewardProps = { onClick: () => void; @@ -70,10 +68,13 @@ const Reward: FunctionComponent = ({ return (
-
-

Reward:

- -

{reward}

+
+

Reward:

+
+

{reward}

+ +
+
{/* getReward */} diff --git a/styles/components/quests/card.module.css b/styles/components/quests/card.module.css index 5cb7020e..ab750c0a 100644 --- a/styles/components/quests/card.module.css +++ b/styles/components/quests/card.module.css @@ -35,8 +35,12 @@ font-size: 1.3rem; color: var(--secondary); font-family: "Sora-Bold"; - margin: 0px; + margin: 0; text-align: left; + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden; + width: 240px; } .card[aria-disabled="true"] { diff --git a/styles/questboost.module.css b/styles/questboost.module.css index 733b69a9..11cfe955 100644 --- a/styles/questboost.module.css +++ b/styles/questboost.module.css @@ -52,16 +52,12 @@ font-size: 1.2rem; color: var(--secondary); font-family: "Sora-Bold"; - margin: 0px; - text-align: left; -} - -.card_title { - font-size: 1.2rem; - color: var(--secondary); - font-family: "Sora-Bold"; - margin: 0px; + margin: 0; text-align: left; + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden; + width: 210px; } .issuer { @@ -87,7 +83,7 @@ justify-content: space-between; align-items: center; border-radius: 0.5rem; - background: #29282b; + background: var(--menu-background); box-shadow: 0px 2px 30px 0px rgba(16, 16, 18, 0.06); } diff --git a/styles/quests.module.css b/styles/quests.module.css index 75715ef8..9ed9beb4 100644 --- a/styles/quests.module.css +++ b/styles/quests.module.css @@ -70,8 +70,7 @@ max-width: 90%; width: 728px; - /* Background/600 */ - background: #29282b; + background-color: var(--menu-background); border-radius: 8px; cursor: url(../public/icons/pointer-cursor.png), pointer; padding: 5px 24px; @@ -170,8 +169,7 @@ max-width: 90%; margin-top: 1.5rem; - /* Background/600 */ - background: #29282b; + background-color: var(--menu-background); /* Small Shadow */ box-shadow: 0px 2px 30px rgba(16, 16, 18, 0.06); @@ -249,15 +247,12 @@ .issuer { display: flex; - margin-top: 0.5rem; - margin-bottom: 0.25rem; /* Auto layout */ flex-direction: row; justify-content: center; align-items: center; - padding: 8px 24px; + padding: 4px 1rem; gap: 10px; - margin-top: 1rem; height: 36px; /* Background/600 */ background: var(--background600);