Skip to content
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
7 changes: 6 additions & 1 deletion src/components/ChallengeEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,12 @@ class ChallengeEditor extends Component {
for (let phaseIndex = index + 1; phaseIndex < phases.length; phaseIndex++) {
if (moment(phases[phaseIndex]['scheduledStartDate']).isBefore(lastDate)) {
lastDate = moment(lastDate).add('1', 'hour').format('MM/DD/YYYY HH:mm')
newChallenge.phases[phaseIndex]['scheduledStartDate'] = lastDate

if (newChallenge.phases[phaseIndex]['name'] !== 'Submission') {
newChallenge.phases[phaseIndex]['scheduledStartDate'] = lastDate
} else {
newChallenge.phases[phaseIndex]['scheduledStartDate'] = newChallenge.phases[index]['scheduledStartDate']
}

if (moment(phases[phaseIndex]['scheduledEndDate']).isBefore(lastDate)) {
lastDate = moment(lastDate).add('1', 'hour').format('MM/DD/YYYY HH:mm')
Expand Down
13 changes: 13 additions & 0 deletions src/components/PhaseInput/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import '@nateradebaugh/react-datetime/scss/styles.scss'
import DurationInput from '../DurationInput'

const dateFormat = 'MM/DD/YYYY HH:mm'
const inputDateFormat = 'MM/dd/yyyy'
const inputTimeFormat = 'HH:mm'
const MAX_LENGTH = 5

const PhaseInput = ({ onUpdatePhase, phase, readOnly, phaseIndex, isActive }) => {
Expand All @@ -25,6 +27,13 @@ const PhaseInput = ({ onUpdatePhase, phase, readOnly, phaseIndex, isActive }) =>
setEndDate(phase.scheduledEndDate)
setDuration(moment(phase.scheduledEndDate).diff(phase.scheduledStartDate, 'hours'))
}
}, [])

useEffect(() => {
if (phase) {
setStartDate(phase.scheduledStartDate)
setEndDate(phase.scheduledEndDate)
}
}, [phase])

useEffect(() => {
Expand Down Expand Up @@ -94,6 +103,8 @@ const PhaseInput = ({ onUpdatePhase, phase, readOnly, phaseIndex, isActive }) =>
return isAfter(current, yesterday)
}}
disabled={!isActive}
dateFormat={inputDateFormat}
timeFormat={inputTimeFormat}
/>)}
</div>
</div>
Expand All @@ -113,6 +124,8 @@ const PhaseInput = ({ onUpdatePhase, phase, readOnly, phaseIndex, isActive }) =>
return isAfter(current, new Date(startDate))
}}
disabled={!isActive}
dateFormat={inputDateFormat}
timeFormat={inputTimeFormat}
/>)}
</div>
</div>
Expand Down