Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ workflows:
only:
- develop
- PM-3087_virus-scan-fix
- PM-3541_home-points-challenge

- "build-prod":
context: org-global
Expand Down
44 changes: 25 additions & 19 deletions src/shared/components/Dashboard/Challenges/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,32 @@ export default function ChallengesFeed({
<LoadingIndicator />
</div>
) : (
(challenges || []).map(challenge => (
<div styleName="row" key={challenge.id}>
<a
href={`/challenges/${challenge.id}`}
target="_blank"
rel="noreferrer"
>
{challenge.name}
</a>
<div styleName="prize">
<span styleName="amount">
{`$${_.sum(
challenge.prizeSets
.filter(set => set.type === 'PLACEMENT')
.map(item => _.sum(item.prizes.map(prize => prize.value))),
).toLocaleString()}`}
</span>
(challenges || []).map((challenge) => {
const placementPrizes = challenge.prizeSets
.filter(set => set.type === 'PLACEMENT')
.flatMap(item => item.prizes);
const prizeTotal = _.sum(placementPrizes.map(prize => prize.value));
const prizeType = placementPrizes.length > 0 ? placementPrizes[0].type : null;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[❗❗ correctness]
The logic assumes that all prizes in placementPrizes have the same type. If there is a mix of prize types, this could lead to incorrect behavior. Consider verifying that all prize types are consistent or handling mixed types appropriately.

const isPointBasedPrize = prizeType === 'POINT';
const prizeSymbol = isPointBasedPrize ? '' : '$';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[❗❗ correctness]
The variable prizeSymbol is determined based on the first prize's type. If placementPrizes contains a mix of types, this could result in an incorrect symbol being displayed. Ensure that the prize type check is robust against such cases.


return (
<div styleName="row" key={challenge.id}>
<a
href={`/challenges/${challenge.id}`}
target="_blank"
rel="noreferrer"
>
{challenge.name}
</a>
<div styleName="prize">
<span styleName="amount">
{`${prizeSymbol}${prizeTotal.toLocaleString()}`}
</span>
</div>
</div>
</div>
))
);
})
)}
</div>
</div>
Expand Down
Loading