99 PRIZE_SETS_TYPE ,
1010 CHALLENGE_PRIZE_TYPE ,
1111 MAX_CHECKPOINT_PRIZE_COUNT ,
12- DEFAULT_CHECKPOINT_PRIZE
12+ DEFAULT_CHECKPOINT_PRIZE ,
13+ DEFAULT_CHECKPOINT_PRIZE_COUNT
1314} from '../../../config/constants'
1415import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
1516import { faDollarSign } from '@fortawesome/free-solid-svg-icons'
@@ -19,7 +20,7 @@ const CheckpointPrizesField = ({ challenge, onUpdateOthers, readOnly }) => {
1920 const type = PRIZE_SETS_TYPE . CHECKPOINT_PRIZES
2021 const prizeSets = _ . get ( challenge , 'prizeSets' ) || [ ]
2122 const checkpointPrize = prizeSets . find ( p => p . type === type ) || { type : PRIZE_SETS_TYPE . CHECKPOINT_PRIZES , prizes : [ ] , 'description' : 'Checkpoint Prizes' }
22- const number = _ . get ( checkpointPrize , 'prizes.length' ) || MAX_CHECKPOINT_PRIZE_COUNT
23+ const number = _ . get ( checkpointPrize , 'prizes.length' ) || DEFAULT_CHECKPOINT_PRIZE_COUNT
2324 const amount = _ . get ( checkpointPrize , 'prizes.length' ) ? checkpointPrize . prizes [ 0 ] . value : DEFAULT_CHECKPOINT_PRIZE
2425
2526 // update the check point prize with default values if it's not already defined
@@ -39,42 +40,41 @@ const CheckpointPrizesField = ({ challenge, onUpdateOthers, readOnly }) => {
3940 < div className = { cn ( styles . field , styles . col1 ) } >
4041 < label htmlFor = { `checkpointPrizes` } className = { styles . checkpointLabel } > Checkpoint Prizes :</ label >
4142 </ div >
42- </ div >
43- {
44- readOnly ? (
45- < div className = { styles . checkpointPrizeContainer } >
43+ {
44+ readOnly ? (
45+ < div className = { cn ( styles . field , styles . col2 ) } >
4646 ${ amount } for each submission up to { number } submissions
47- </ div >
48- ) : (
49- < div className = { styles . checkpointPrizeContainer } >
50- < div >
51- Pay
5247 </ div >
53- < div >
54- < div className = { styles . checkpointPrizeInputContainer } >
55- < div className = { styles . checkpointPrizeAmountContainer } >
56- < FontAwesomeIcon className = { styles . dollarIcon } icon = { faDollarSign } />
48+ ) : (
49+ < div className = { cn ( styles . field , styles . col2 ) } >
50+ < div >
51+ Pay
52+ </ div >
53+ < div >
54+ < div className = { styles . checkpointPrizeInputContainer } >
55+ < div className = { styles . checkpointPrizeAmountContainer } >
56+ < FontAwesomeIcon className = { styles . dollarIcon } icon = { faDollarSign } />
57+ </ div >
58+ < input id = 'checkpointPrize' name = 'checkpointPrize' type = 'text' placeholder = '' value = { amount } maxLength = '7' required onChange = { ( e ) => onChange ( number , e . target . value ) } />
5759 </ div >
58- < input id = 'checkpointPrize' name = 'checkpointPrize' type = 'text' placeholder = '' value = { amount } maxLength = '7' required onChange = { ( e ) => onChange ( number , e . target . value ) } />
60+ </ div >
61+ < div >
62+ for each submission up to
63+ </ div >
64+ < div className = { styles . checkpointSelect } >
65+ < Select
66+ name = 'submissions'
67+ options = { _ . range ( 1 , MAX_CHECKPOINT_PRIZE_COUNT + 1 ) . map ( ( v ) => ( { label : v , value : v } ) ) }
68+ value = { { label : number , value : number } }
69+ isClearable = { false }
70+ onChange = { e => onChange ( e . value , amount ) }
71+ isDisabled = { false }
72+ />
5973 </ div >
6074 </ div >
61- < div >
62- for each submission up to
63- </ div >
64- < div >
65- < Select
66- name = 'submissions'
67- options = { _ . range ( 1 , MAX_CHECKPOINT_PRIZE_COUNT + 1 ) . map ( ( v ) => ( { label : v , value : v } ) ) }
68- value = { { label : number , value : number } }
69- isClearable = { false }
70- onChange = { e => onChange ( e . value , amount ) }
71- isDisabled = { false }
72- />
73- </ div >
74-
75- </ div >
76- )
77- }
75+ )
76+ }
77+ </ div >
7878 </ >
7979 )
8080}
0 commit comments