Skip to content

Commit

Permalink
feat: filter done quests in trending
Browse files Browse the repository at this point in the history
  • Loading branch information
Marchand-Nicolas committed Jan 20, 2024
1 parent 8059491 commit d7c9f7b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
12 changes: 7 additions & 5 deletions context/QuestsProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,13 @@ export const QuestsContextProvider = ({
}, []);

useMemo(() => {
getTrendingQuests().then((data: QuestDocument[] | QueryError) => {
if ((data as QueryError).error) return;
setTrendingQuests(data as QuestDocument[]);
});
}, []);
getTrendingQuests(hexToDecimal(address)).then(
(data: QuestDocument[] | QueryError) => {
if ((data as QueryError).error) return;
setTrendingQuests(data as QuestDocument[]);
}
);
}, [address]);

useMemo(() => {
if (!address) return;
Expand Down
6 changes: 4 additions & 2 deletions services/apiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,11 @@ export const getQuests = async () => {
}
};

export const getTrendingQuests = async () => {
export const getTrendingQuests = async (addr = "") => {
try {
const response = await fetch(`${baseurl}/get_trending_quests`);
const response = await fetch(
`${baseurl}/get_trending_quests${addr ? `?addr=${addr}` : ""}`
);
return await response.json();
} catch (err) {
console.log("Error while fetching trending quests", err);
Expand Down

0 comments on commit d7c9f7b

Please sign in to comment.