File tree Expand file tree Collapse file tree 3 files changed +18
-3
lines changed
components/ChallengeEditor Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ import { isBetaMode } from '../../util/cookie'
6868import MilestoneField from './Milestone-Field'
6969import DiscussionField from './Discussion-Field'
7070import CheckpointPrizesField from './CheckpointPrizes-Field'
71+ import { canChangeDuration } from '../../util/phase'
7172
7273const theme = {
7374 container : styles . modalContainer
@@ -843,8 +844,7 @@ class ChallengeEditor extends Component {
843844 const is2RoundDesignChallenge = isDesignChallenge && is2RoundChallenge
844845
845846 for ( let index = 0 ; index < phases . length ; ++ index ) {
846- newChallenge . phases [ index ] . isDurationActive =
847- moment ( newChallenge . phases [ index ] [ 'scheduledEndDate' ] ) . isAfter ( )
847+ newChallenge . phases [ index ] . isDurationActive = canChangeDuration ( newChallenge . phases [ index ] )
848848 if ( ( newChallenge . phases [ index ] . name === 'Submission' && ! is2RoundDesignChallenge ) || newChallenge . phases [ index ] . name === 'Checkpoint Submission' ) {
849849 newChallenge . phases [ index ] . isStartTimeActive = true
850850 } else {
Original file line number Diff line number Diff line change 44import moment from 'moment'
55import _ from 'lodash'
66import 'moment-duration-format'
7+ import { canChangeDuration } from './phase'
78
89const HOUR_MS = 60 * 60 * 1000
910const DAY_MS = 24 * HOUR_MS
@@ -120,7 +121,13 @@ export const getRoundFormattedDuration = (duration) => {
120121export const convertChallengePhaseFromSecondsToHours = ( phases ) => {
121122 if ( phases ) {
122123 _ . forEach ( phases , ( p ) => {
123- p . duration = Math . floor ( p . duration / minuteToSecond )
124+ if ( canChangeDuration ( p ) ) {
125+ p . duration = Math . floor ( p . duration / minuteToSecond )
126+ } else {
127+ // use the same duration display as OR, as long as we aren't changing the fields that should be fine.
128+ const duration = moment . duration ( moment ( p . scheduledEndDate ) . diff ( moment ( p . scheduledStartDate ) ) )
129+ p . duration = Math . ceil ( duration . asMinutes ( ) )
130+ }
124131 } )
125132 }
126133}
Original file line number Diff line number Diff line change 1+ import moment from 'moment'
2+
3+ export const canChangeDuration = phase => {
4+ if ( ! phase ) {
5+ return false
6+ }
7+ return moment ( phase . scheduledEndDate ) . isAfter ( )
8+ }
You can’t perform that action at this time.
0 commit comments