Skip to content

Commit 01e2f2e

Browse files
committed
Merge branch 'develop' into feature/timeline-template
2 parents f8f223e + 627a5b1 commit 01e2f2e

File tree

17 files changed

+263
-114
lines changed

17 files changed

+263
-114
lines changed

.circleci/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ builddeploy_steps: &builddeploy_steps
3333
command: |
3434
./awsconfiguration.sh $DEPLOY_ENV
3535
./buildenv.sh -e $DEPLOY_ENV -b ${LOGICAL_ENV}-${APPNAME}-buildvar
36+
echo awsenvconf >.dockerignore
37+
echo buildenvvar >>.dockerignore
3638
- run:
3739
name: "building image"
3840
command: |

server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function check () {
1717
}
1818
app.use(healthCheck.middleware([check]))
1919
// app.use(requireHTTPS) // removed because app servers don't handle https
20-
app.use(express.static(__dirname))
20+
// app.use(express.static(__dirname))
2121
app.use(express.static(path.join(__dirname, 'build')))
2222
app.get('/*', (req, res) => res.sendFile(path.join(__dirname, 'build', 'index.html')))
2323
const port = process.env.PORT || 3000

src/actions/challenges.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,10 @@ export function createChallenge (challengeDetails) {
245245
type: CREATE_CHALLENGE_SUCCESS,
246246
challengeDetails: challenge
247247
})
248-
}).catch(() => {
248+
}).catch((e) => {
249249
dispatch({
250-
type: CREATE_CHALLENGE_FAILURE
250+
type: CREATE_CHALLENGE_FAILURE,
251+
error: e
251252
})
252253
})
253254
}

src/components/ChallengeEditor/AssignedMember-Field/AssignedMember-Field.module.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
display: flex;
4040
flex-direction: row;
4141
flex-wrap: wrap;
42+
min-width: 280px;
4243
}
4344
}
4445

src/components/ChallengeEditor/ChallengeEditor.module.scss

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
span {
2929
color: $tc-red;
3030
}
31+
3132
}
3233

3334
.textRequired {
@@ -232,10 +233,13 @@
232233
}
233234

234235
.error {
235-
text-align: right;
236236
padding-right: 40px;
237237
padding-bottom: 20px;
238-
color: $tc-red
238+
color: $tc-red;
239+
240+
.errorMessage {
241+
font-size: 25px;
242+
}
239243
}
240244

241245
.actionButtons {
@@ -332,6 +336,7 @@
332336
line-height: 36px;
333337
margin-bottom: 30px;
334338
margin-top: 0;
339+
335340
}
336341

337342
span {

src/components/ChallengeEditor/ChallengePrizes-Field/index.js

Lines changed: 99 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ import PrizeInput from '../../PrizeInput'
88
import styles from './ChallengePrizes-Field.module.scss'
99
import cn from 'classnames'
1010
import { PrimaryButton } from '../../Buttons'
11-
import { CHALLENGE_PRIZE_TYPE, VALIDATION_VALUE_TYPE, PRIZE_SETS_TYPE, CHALLENGE_TYPES_WITH_MULTIPLE_PRIZES } from '../../../config/constants'
11+
import {
12+
CHALLENGE_PRIZE_TYPE,
13+
VALIDATION_VALUE_TYPE,
14+
PRIZE_SETS_TYPE,
15+
CHALLENGE_TYPES_WITH_MULTIPLE_PRIZES
16+
} from '../../../config/constants'
1217
import { validateValue } from '../../../util/input-check'
1318

1419
class ChallengePrizesField extends Component {
@@ -26,7 +31,10 @@ class ChallengePrizesField extends Component {
2631

2732
addNewPrize () {
2833
const challengePrize = this.getChallengePrize()
29-
challengePrize.prizes = [...challengePrize.prizes, { type: CHALLENGE_PRIZE_TYPE.USD, value: 1 }]
34+
challengePrize.prizes = [
35+
...challengePrize.prizes,
36+
{ type: CHALLENGE_PRIZE_TYPE.USD, value: 1 }
37+
]
3038
this.onUpdateValue(challengePrize)
3139
}
3240

@@ -38,7 +46,10 @@ class ChallengePrizesField extends Component {
3846

3947
onUpdateInput (value, index) {
4048
const challengePrize = this.getChallengePrize()
41-
challengePrize.prizes[index].value = validateValue(value, VALIDATION_VALUE_TYPE.INTEGER)
49+
challengePrize.prizes[index].value = validateValue(
50+
value,
51+
VALIDATION_VALUE_TYPE.INTEGER
52+
)
4253
if (parseInt(challengePrize.prizes[index].value) > 1000000) {
4354
challengePrize.prizes[index].value = '1000000'
4455
}
@@ -48,71 +59,115 @@ class ChallengePrizesField extends Component {
4859
onUpdateValue (challengePrize) {
4960
const type = PRIZE_SETS_TYPE.CHALLENGE_PRIZES
5061
const { onUpdateOthers, challenge } = this.props
51-
const existingPrizes = challenge.prizeSets ? challenge.prizeSets.filter(p => p.type !== type) : []
62+
const existingPrizes = challenge.prizeSets
63+
? challenge.prizeSets.filter(p => p.type !== type)
64+
: []
5265

53-
onUpdateOthers({ field: 'prizeSets', value: [...existingPrizes, challengePrize] })
66+
onUpdateOthers({
67+
field: 'prizeSets',
68+
value: [...existingPrizes, challengePrize]
69+
})
5470
}
5571

5672
getChallengePrize () {
5773
const type = PRIZE_SETS_TYPE.CHALLENGE_PRIZES
58-
return (this.props.challenge.prizeSets && this.props.challenge.prizeSets.length && this.props.challenge.prizeSets.find(p => p.type === type)) || { type, prizes: [{ type: CHALLENGE_PRIZE_TYPE.USD, value: 0 }] }
74+
return (
75+
(this.props.challenge.prizeSets &&
76+
this.props.challenge.prizeSets.length &&
77+
this.props.challenge.prizeSets.find(p => p.type === type)) || {
78+
type,
79+
prizes: [{ type: CHALLENGE_PRIZE_TYPE.USD, value: 0 }]
80+
}
81+
)
5982
}
6083

6184
renderPrizes () {
6285
const { currentPrizeIndex } = this.state
6386
const { readOnly, challenge } = this.props
64-
const allowMultiplePrizes = _.includes(CHALLENGE_TYPES_WITH_MULTIPLE_PRIZES, challenge.type)
65-
return _.map(this.getChallengePrize().prizes, (prize, index, { length }) => (
66-
<div key={`${index}-${prize.amount}-edit`}>
67-
<div className={styles.row}>
68-
<div className={cn(styles.field, styles.col1)}>
69-
<label htmlFor={`${index}-prize`}>Prize {allowMultiplePrizes ? index + 1 : ''} {!readOnly && (<span>*</span>)}:</label>
70-
</div>
71-
{readOnly ? (
72-
<span>${prize.value}</span>
73-
) : (<div className={cn(styles.field, styles.col2)}>
74-
<PrizeInput
75-
prize={prize}
76-
isFocus={index === currentPrizeIndex}
77-
onUpdateInput={this.onUpdateInput}
78-
index={index} activeIndex={currentPrizeIndex} />
79-
{
80-
index > 0 && (
81-
<div className={styles.icon} onClick={() => this.removePrize(index)}>
82-
<FontAwesomeIcon icon={faTrash} />
87+
const allowMultiplePrizes = _.includes(
88+
CHALLENGE_TYPES_WITH_MULTIPLE_PRIZES,
89+
challenge.type
90+
)
91+
return _.map(
92+
this.getChallengePrize().prizes,
93+
(prize, index, { length }) => {
94+
let errMessage = ''
95+
if (prize.value === '') {
96+
errMessage = 'Prize amount is required field'
97+
} else if (+prize.value <= 0 || +prize.value > 1000000) {
98+
errMessage =
99+
'Prize amount must be more than 0 and no more than 1000000'
100+
} else if (index > 0) {
101+
const prePrize = this.getChallengePrize().prizes[index - 1]
102+
if (+prePrize.value < +prize.value) {
103+
errMessage =
104+
'Prize for the higher place cannot be bigger than for lower place'
105+
}
106+
}
107+
return (
108+
<div key={`${index}-${prize.amount}-edit`}>
109+
<div className={styles.row}>
110+
<div className={cn(styles.field, styles.col1)}>
111+
<label htmlFor={`${index}-prize`}>
112+
Prize {allowMultiplePrizes ? index + 1 : ''}{' '}
113+
{!readOnly && <span>*</span>}:
114+
</label>
115+
</div>
116+
{readOnly ? (
117+
<span>${prize.value}</span>
118+
) : (
119+
<div className={cn(styles.field, styles.col2)}>
120+
<PrizeInput
121+
prize={prize}
122+
isFocus={index === currentPrizeIndex}
123+
onUpdateInput={this.onUpdateInput}
124+
index={index}
125+
activeIndex={currentPrizeIndex}
126+
/>
127+
{index > 0 && (
128+
<div
129+
className={styles.icon}
130+
onClick={() => this.removePrize(index)}
131+
>
132+
<FontAwesomeIcon icon={faTrash} />
133+
</div>
134+
)}
83135
</div>
84-
)
85-
}
86-
</div>)}
87-
</div>
88-
{!readOnly && challenge.submitTriggered && (prize.value === '' || (+prize.value <= 0 || +prize.value > 1000000)) && (
89-
<div className={styles.row}>
90-
<div className={cn(styles.field, styles.col1)} />
91-
<div className={cn(styles.field, styles.col2, styles.error)}>
92-
{prize.value === ''
93-
? 'Prize amount is required field'
94-
: 'Prize amount must be more than 0 and no more than 1000000'}
136+
)}
95137
</div>
138+
{!readOnly && challenge.submitTriggered && errMessage && (
139+
<div className={styles.row}>
140+
<div className={cn(styles.field, styles.col1)} />
141+
<div className={cn(styles.field, styles.col2, styles.error)}>
142+
{errMessage}
143+
</div>
144+
</div>
145+
)}
96146
</div>
97-
)}
98-
</div>
99-
))
147+
)
148+
}
149+
)
100150
}
101151

102152
render () {
103153
const { readOnly, challenge } = this.props
104-
const allowMultiplePrizes = _.includes(CHALLENGE_TYPES_WITH_MULTIPLE_PRIZES, challenge.type)
154+
const allowMultiplePrizes = _.includes(
155+
CHALLENGE_TYPES_WITH_MULTIPLE_PRIZES,
156+
challenge.type
157+
)
105158
return (
106159
<div className={styles.container}>
107160
<div className={styles.row}>
108161
<div className={cn(styles.field, styles.col1)}>
109162
<label htmlFor={`challengePrizes`}>Challenge Prizes :</label>
110163
</div>
111164
</div>
112-
{ this.renderPrizes() }
113-
{!readOnly && allowMultiplePrizes && (<div className={styles.button} onClick={this.addNewPrize}>
114-
<PrimaryButton text={'Add New Prize'} type={'info'} />
115-
</div>)}
165+
{this.renderPrizes()}
166+
{!readOnly && allowMultiplePrizes && (
167+
<div className={styles.button} onClick={this.addNewPrize}>
168+
<PrimaryButton text={'Add New Prize'} type={'info'} />
169+
</div>
170+
)}
116171
</div>
117172
)
118173
}

src/components/ChallengeEditor/ChallengeTotal-Field/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const ChallengeTotalField = ({ challenge }) => {
1111
challengeTotal = _.flatten(challenge.prizeSets.map(p => p.prizes))
1212
.map(p => p.value)
1313
.map(v => convertDollarToInteger(v, '$'))
14-
.map(v => +v)
1514
.reduce((prev, next) => prev + next, 0)
1615
}
1716
return (

src/components/ChallengeEditor/ChallengeView/index.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,17 @@ const ChallengeView = ({
8787
return (
8888
<div className={styles.wrapper}>
8989
<Helmet title='View Details' />
90-
<div className={cn(styles.actionButtons, styles.button, styles.actionButtonsLeft)}>
91-
<LegacyLinks challenge={challenge} />
92-
</div>
90+
{!isTask && (
91+
<div className={cn(styles.actionButtons, styles.button, styles.actionButtonsLeft)}>
92+
<LegacyLinks challenge={challenge} />
93+
</div>
94+
)}
9395
<div className={styles.title}>View Details</div>
9496
<div className={cn(styles.actionButtons, styles.button, styles.actionButtonsRight)}>
9597
{
9698
challenge.status === 'Draft' && (
9799
<div className={styles.button}>
98-
{challenge.legacyId ? (
100+
{(challenge.legacyId || isTask) ? (
99101
<PrimaryButton text={'Launch'} type={'info'} onClick={onLaunchChallenge} />
100102
) : (
101103
<Tooltip content={MESSAGE.NO_LEGACY_CHALLENGE}>
@@ -190,16 +192,14 @@ const ChallengeView = ({
190192
<span><span className={styles.fieldTitle}>Groups:</span> {groups}</span>
191193
</div>
192194
</div>
193-
{isBetaMode() && (
194-
<div className={styles.row}>
195-
<div className={styles.col}>
196-
<span>
197-
<span className={styles.fieldTitle}>Billing Account Id:</span>
198-
{projectDetail.billingAccountId}
199-
</span>
200-
</div>
195+
<div className={styles.row}>
196+
<div className={styles.col}>
197+
<span>
198+
<span className={styles.fieldTitle}>Billing Account Id:</span>
199+
{projectDetail.billingAccountId}
200+
</span>
201201
</div>
202-
)}
202+
</div>
203203
{isBetaMode() && (
204204
<UseSchedulingAPIField challenge={challenge} readOnly />
205205
)}

0 commit comments

Comments
 (0)