Skip to content

Commit 3a9c780

Browse files
refactor: use a variable for code readability
1 parent 8bb2a12 commit 3a9c780

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/components/cards/challenge/Challenge.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export default function ChallengeCard({ data, community, isCourseEnd }: Challeng
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;
3333
const totalReward = data?.rewards?.reduce((acc, reward) => (acc += Number(reward.amount)), 0);
34+
const prize = `${shortenNumber(totalReward)} ${reward?.fiatCurrency ? `${reward?.fiatCurrency} in` : ''} ${reward?.token} ${data?.isHackathon ? `Prize pool` : ""} rewards`
3435

3536
return (
3637
<div className="border-solid border border-gray-200 bg-gray-50 rounded-3xl mb-5 group text-gray-700">
@@ -60,7 +61,7 @@ export default function ChallengeCard({ data, community, isCourseEnd }: Challeng
6061
<div className="md:pl-2 max-w-max">
6162
<div className="flex text-sm text-gray-700">
6263
<span className="block font-medium">
63-
{shortenNumber(totalReward)} {reward?.fiatCurrency ? `${reward?.fiatCurrency} in` : ''} {reward?.token} {` ${data?.isHackathon ? `Prize pool` : ""} rewards`}
64+
{prize}
6465
</span>
6566
</div>
6667
<div className="text-gray-400 text-xs font-normal">{data?.isHackathon ? "Top projects win money prizes" : "For submission and feedback"}</div>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import { shortenNumber } from "@/utilities";
33

44
export default function HackathonPrize({ reward, description }: { reward: Reward; description: string }) {
55
const { first, second, third } = reward?.distribution || ({} as Distribution);
6+
const totalPrize = `${shortenNumber(reward?.amount)} ${reward?.fiatCurrency ? `${reward?.fiatCurrency} in` : ''} ${reward.token} Prize Pool`;
67
return (
78
<>
89
<div className="flex gap-1 text-gray-700 font-medium">
9-
<span>{`${shortenNumber(reward?.amount)} ${reward?.fiatCurrency ? `${reward?.fiatCurrency} in` : ''} ${reward.token} Prize Pool`}</span>
10+
<span>{totalPrize}</span>
1011
<span>{description}</span>
1112
</div>
1213
<div className="text-gray-400 text-xs font-medium leading-3 mt-1 flex">

0 commit comments

Comments
 (0)