Skip to content

Commit

Permalink
feat: add boosted quests endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushtom committed Jan 8, 2024
1 parent 0aef4ab commit 1b96a3f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
23 changes: 19 additions & 4 deletions components/quests/quest.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import React, { FunctionComponent, useMemo } from "react";
import React, {
FunctionComponent,
useCallback,
useEffect,
useMemo,
useState,
} from "react";
import { useContext } from "react";
import { QuestsContext } from "@context/QuestsProvider";
import CheckIcon from "@components/UI/iconsComponents/icons/checkIcon";
import UnavailableIcon from "@components/UI/iconsComponents/icons/unavailableIcon";
import styles from "@styles/quests.module.css";
import { CDNImg } from "@components/cdn/image";
import QuestCard from "./questCard";

const BOOSTED_QUESTS = [23, 104];
import { getBoostedQuests } from "@services/apiService";

type QuestProps = {
onClick: () => void;
Expand All @@ -33,6 +38,16 @@ const Quest: FunctionComponent<QuestProps> = ({
() => completedQuestIds.includes(id),
[id, completedQuestIds]
);
const [boostedQuests, setBoostedQuests] = useState<number[]>([]);

const fetchBoostedQuests = useCallback(async () => {
const response = await getBoostedQuests();
setBoostedQuests(response);
}, []);

useEffect(() => {
fetchBoostedQuests();
}, []);

return (
<QuestCard
Expand Down Expand Up @@ -67,7 +82,7 @@ const Quest: FunctionComponent<QuestProps> = ({
</>
)}
</div>
{BOOSTED_QUESTS.includes(id) ? (
{boostedQuests.includes(id) ? (
<div
className={styles.issuer}
style={{ gap: 0, padding: "8px 16px" }}
Expand Down
9 changes: 9 additions & 0 deletions services/apiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,12 @@ export const getPendingBoostClaims = async (addr: string) => {
console.log(err);
}
};

export const getBoostedQuests = async () => {
try {
const response = await fetch(`${baseurl}/get_boosted_quests`);
return await response.json();
} catch (err) {
console.log(err);
}
};

0 comments on commit 1b96a3f

Please sign in to comment.