-
Notifications
You must be signed in to change notification settings - Fork 51
Points support updates #1714
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
Points support updates #1714
Conversation
| import cn from 'classnames' | ||
| import { PrimaryButton, OutlineButton } from '../../Buttons' | ||
| import { REVIEW_OPPORTUNITY_TYPE_LABELS, REVIEW_OPPORTUNITY_TYPES, VALIDATION_VALUE_TYPE, MARATHON_TYPE_ID, DES_TRACK_ID, CHALLENGE_PRIZE_TYPE } from '../../../config/constants' | ||
| import { REVIEW_OPPORTUNITY_TYPE_LABELS, REVIEW_OPPORTUNITY_TYPES, VALIDATION_VALUE_TYPE, MARATHON_TYPE_ID, DES_TRACK_ID } from '../../../config/constants' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[❗❗ correctness]
The import of CHALLENGE_PRIZE_TYPE has been removed, but it is still used in the code. Ensure that this constant is either re-imported or that its usage is removed or replaced.
| getFirstPlacePrizeValue (challenge) { | ||
| const prizeSets = challenge.prizeSets || [] | ||
| const placementPrizeSet = prizeSets.find(set => set.type === 'PLACEMENT') | ||
| const placementPrizeSet = challenge.prizeSets.find(set => set.type === 'PLACEMENT') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[correctness]
The change assumes challenge.prizeSets is always defined, which may not be the case. Consider adding a check to ensure challenge.prizeSets is defined before calling .find() to avoid potential runtime errors.
| const number = _.get(checkpointPrize, 'prizes.length') || DEFAULT_CHECKPOINT_PRIZE_COUNT | ||
| const amount = _.get(checkpointPrize, 'prizes.length') ? checkpointPrize.prizes[0].value : DEFAULT_CHECKPOINT_PRIZE | ||
| const prizeType = getPrizeType(prizeSets) | ||
| const prizeType = _.get(checkpointPrize, 'prizes[0].type') || getPrizeType(prizeSets) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[❗❗ correctness]
The use of _.get(checkpointPrize, 'prizes[0].type') assumes that prizes is an array and that prizes[0] exists. Consider adding a check to ensure prizes is an array and has at least one element to avoid potential runtime errors.
| ? <span className={styles.pointsLabel}>Pts</span> | ||
| : <FontAwesomeIcon className={styles.dollarIcon} icon={faDollarSign} />} | ||
| </div> | ||
| <input id='checkpointPrize' name='checkpointPrize' type='text' placeholder='' value={amount} maxLength='7' required onChange={(e) => onChange(number, e.target.value)} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[maintainability]
The input element uses type='text' for a field that appears to represent a numeric value (amount). Consider using type='number' to leverage built-in browser validation and improve user experience.
No description provided.