Skip to content

Fix prizeSets logical to get 'placements' instead first one #5204

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 19, 2020
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
"supertest": "^3.1.0",
"tc-core-library-js": "github:appirio-tech/tc-core-library-js#v2.6.3",
"tc-ui": "^1.0.12",
"topcoder-react-lib": "1.1.2",
"topcoder-react-lib": "1000.25.9",
"topcoder-react-ui-kit": "2.0.1",
"topcoder-react-utils": "0.7.8",
"turndown": "^4.0.2",
Expand Down
3 changes: 2 additions & 1 deletion src/shared/components/challenge-detail/Header/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ export default function ChallengeHeader(props) {
const sortedAllPhases = _.cloneDeep(allPhases)
.sort((a, b) => moment(phaseEndDate(a)).diff(phaseEndDate(b)));

const { prizes } = prizeSets && prizeSets.length ? prizeSets[0] : [];
const placementPrizes = _.find(prizeSets, { type: 'placement' });
const { prizes } = placementPrizes || [];

const checkpointPrizes = _.find(prizeSets, { type: 'checkpoint' });
let numberOfCheckpointsPrizes = 0;
Expand Down
5 changes: 3 additions & 2 deletions src/shared/containers/challenge-detail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,9 @@ class ChallengeDetailPageContainer extends React.Component {

const { prizeSets } = challenge;
let challengePrizes = [];
if (prizeSets && prizeSets[0] && prizeSets[0].type === 'placement') {
challengePrizes = prizeSets[0].prizes;
const placementPrizes = _.find(prizeSets, { type: 'placement' });
if (placementPrizes) {
challengePrizes = placementPrizes.prizes;
}

return (
Expand Down
5 changes: 3 additions & 2 deletions src/shared/utils/challenge-detail/helper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,9 @@ export function getPrizePurseUI(
* @param {Object} challenge challenge info
*/
export function getPrizePointsUI(challenge) {
if (challenge.prizeSets && challenge.prizeSets.length > 0 && challenge.prizeSets[0].prizes) {
const { prizes } = challenge.prizeSets[0];
const placementPrizes = _.find(challenge.prizeSets, { type: 'placement' });
if (placementPrizes) {
const { prizes } = placementPrizes || [];
return (
<Prize
label="Purse"
Expand Down