Skip to content

Commit 91bc144

Browse files
refactor: declare new variables for cleaner code
1 parent ebe1428 commit 91bc144

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/components/cards/challenge/Challenge.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default function ChallengeCard({ data, community, isCourseEnd }: Challeng
3030
const link = `/communities/${community.slug}/challenges/${data.id}`;
3131
const expiresAt = useMemo(() => (data.expiresAt ? new Date(data.expiresAt).toLocaleDateString() : null), [data.expiresAt]);
3232
const reward = isCourseEnd ? data?.rewards?.find((reward) => reward.type === "SUBMISSION") : data?.reward;
33-
const totalReward = data?.rewards?.reduce((acc, reward) => (acc += Number(reward.amount)), 0);
33+
const amount = shortenNumber(data?.rewards?.reduce((acc, reward) => (acc += Number(reward.amount)), 0));
3434

3535
return (
3636
<div className="border-solid border border-gray-200 bg-gray-50 rounded-3xl mb-5 group text-gray-700">
@@ -61,9 +61,9 @@ export default function ChallengeCard({ data, community, isCourseEnd }: Challeng
6161
<div className="flex text-sm text-gray-700">
6262
<span className="block font-medium">
6363
{data?.isHackathon ? <>{reward?.fiatCurrency ?
64-
t('communities.overview.reward.fiat.prize.pool', { amount: shortenNumber(totalReward), currency: reward.fiatCurrency, token: reward?.token }) :
65-
t('communities.overview.reward.crypto.prize.pool', { amount: shortenNumber(totalReward), token: reward?.token })
66-
} </> : <>{shortenNumber(totalReward)} {reward?.token} </>}
64+
t('communities.overview.reward.fiat.prize.pool', { amount, currency: reward.fiatCurrency, token: reward?.token }) :
65+
t('communities.overview.reward.crypto.prize.pool', { amount, token: reward?.token })
66+
} </> : <>{amount} {reward?.token} </>}
6767

6868
{t("communities.overview.reward.title")}
6969
</span>

src/components/sections/challenges/_partials/HackathonPrize.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import { useTranslation } from "react-i18next";
55
export default function HackathonPrize({ reward, description }: { reward: Reward; description: string }) {
66
const { t } = useTranslation()
77
const { first, second, third } = reward?.distribution || ({} as Distribution);
8-
8+
const amount = shortenNumber(reward?.amount);
99
return (
1010
<>
1111
<div className="flex gap-1 text-gray-700 font-medium">
1212
<span>
1313
{reward?.fiatCurrency ?
14-
t('communities.overview.reward.fiat.prize.pool', { amount: shortenNumber(reward?.amount), currency: reward.fiatCurrency, token: reward?.token }) :
15-
t('communities.overview.reward.crypto.prize.pool', { amount: shortenNumber(reward?.amount), token: reward?.token })}
14+
t('communities.overview.reward.fiat.prize.pool', { amount, currency: reward.fiatCurrency, token: reward?.token }) :
15+
t('communities.overview.reward.crypto.prize.pool', { amount, token: reward?.token })}
1616
</span>
1717
<span>{description}</span>
1818
</div>

0 commit comments

Comments
 (0)