-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add tags and modify text on cards (#498)
* feat: add tags and modify text on cards * adding boost reward tag
- Loading branch information
1 parent
31330d0
commit 999f377
Showing
12 changed files
with
116 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<BoostRewardProps> = ({ questId }) => { | ||
const { boostedQuests } = useContext(QuestsContext); | ||
const [boost, setBoost] = useState<Boost>(); | ||
const [isQuestBoosted, setIsQuestBoosted] = useState<boolean>(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 ? ( | ||
<div className={styles.issuer} style={{ gap: 0, padding: "8px 16px" }}> | ||
<TokenSymbol tokenAddress={boost?.token} /> | ||
<p className="text-white ml-2">{boost?.amount}</p> | ||
</div> | ||
) : null} | ||
</> | ||
); | ||
}; | ||
|
||
export default BoostReward; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters