@@ -12,6 +12,8 @@ import '@nateradebaugh/react-datetime/scss/styles.scss'
1212import DurationInput from '../DurationInput'
1313
1414const dateFormat = 'MM/DD/YYYY HH:mm'
15+ const inputDateFormat = 'MM/dd/yyyy'
16+ const inputTimeFormat = 'HH:mm'
1517const MAX_LENGTH = 5
1618
1719const PhaseInput = ( { onUpdatePhase, phase, readOnly, phaseIndex, isActive } ) => {
@@ -25,6 +27,13 @@ const PhaseInput = ({ onUpdatePhase, phase, readOnly, phaseIndex, isActive }) =>
2527 setEndDate ( phase . scheduledEndDate )
2628 setDuration ( moment ( phase . scheduledEndDate ) . diff ( phase . scheduledStartDate , 'hours' ) )
2729 }
30+ } , [ ] )
31+
32+ useEffect ( ( ) => {
33+ if ( phase ) {
34+ setStartDate ( phase . scheduledStartDate )
35+ setEndDate ( phase . scheduledEndDate )
36+ }
2837 } , [ phase ] )
2938
3039 useEffect ( ( ) => {
@@ -94,6 +103,8 @@ const PhaseInput = ({ onUpdatePhase, phase, readOnly, phaseIndex, isActive }) =>
94103 return isAfter ( current , yesterday )
95104 } }
96105 disabled = { ! isActive }
106+ dateFormat = { inputDateFormat }
107+ timeFormat = { inputTimeFormat }
97108 /> ) }
98109 </ div >
99110 </ div >
@@ -113,6 +124,8 @@ const PhaseInput = ({ onUpdatePhase, phase, readOnly, phaseIndex, isActive }) =>
113124 return isAfter ( current , new Date ( startDate ) )
114125 } }
115126 disabled = { ! isActive }
127+ dateFormat = { inputDateFormat }
128+ timeFormat = { inputTimeFormat }
116129 /> ) }
117130 </ div >
118131 </ div >
0 commit comments