diff --git a/src/components/ChallengeEditor/index.js b/src/components/ChallengeEditor/index.js index 1c7bc911..bb239e14 100644 --- a/src/components/ChallengeEditor/index.js +++ b/src/components/ChallengeEditor/index.js @@ -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') diff --git a/src/components/PhaseInput/index.js b/src/components/PhaseInput/index.js index a85686fb..e12cf34a 100644 --- a/src/components/PhaseInput/index.js +++ b/src/components/PhaseInput/index.js @@ -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 }) => { @@ -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(() => { @@ -94,6 +103,8 @@ const PhaseInput = ({ onUpdatePhase, phase, readOnly, phaseIndex, isActive }) => return isAfter(current, yesterday) }} disabled={!isActive} + dateFormat={inputDateFormat} + timeFormat={inputTimeFormat} />)} @@ -113,6 +124,8 @@ const PhaseInput = ({ onUpdatePhase, phase, readOnly, phaseIndex, isActive }) => return isAfter(current, new Date(startDate)) }} disabled={!isActive} + dateFormat={inputDateFormat} + timeFormat={inputTimeFormat} />)}