@@ -14,7 +14,7 @@ import DurationInput from '../DurationInput'
1414const dateFormat = 'MM/DD/YYYY HH:mm'
1515const MAX_LENGTH = 5
1616
17- const PhaseInput = ( { onUpdatePhase, phase, readOnly, phaseIndex } ) => {
17+ const PhaseInput = ( { onUpdatePhase, phase, readOnly, phaseIndex, isActive } ) => {
1818 const [ startDate , setStartDate ] = useState ( )
1919 const [ endDate , setEndDate ] = useState ( )
2020 const [ duration , setDuration ] = useState ( )
@@ -86,12 +86,14 @@ const PhaseInput = ({ onUpdatePhase, phase, readOnly, phaseIndex }) => {
8686 )
8787 : (
8888 < DateTime
89+ className = { styles . dateTimeInput }
8990 value = { moment ( startDate ) . format ( dateFormat ) }
9091 onChange = { onStartDateChange }
9192 isValidDate = { ( current ) => {
9293 const yesterday = subDays ( new Date ( ) , 1 )
9394 return isAfter ( current , yesterday )
9495 } }
96+ disabled = { ! isActive }
9597 /> ) }
9698 </ div >
9799 </ div >
@@ -104,11 +106,13 @@ const PhaseInput = ({ onUpdatePhase, phase, readOnly, phaseIndex }) => {
104106 )
105107 : (
106108 < DateTime
109+ className = { styles . dateTimeInput }
107110 value = { moment ( endDate ) . format ( dateFormat ) }
108111 onChange = { onEndDateChange }
109112 isValidDate = { ( current ) => {
110113 return isAfter ( current , new Date ( startDate ) )
111114 } }
115+ disabled = { ! isActive }
112116 /> ) }
113117 </ div >
114118 </ div >
@@ -124,6 +128,7 @@ const PhaseInput = ({ onUpdatePhase, phase, readOnly, phaseIndex }) => {
124128 name = { phase . name }
125129 onDurationChange = { onDurationChange }
126130 index = { phaseIndex }
131+ isActive = { isActive }
127132 /> }
128133 </ div >
129134 </ div >
@@ -134,13 +139,15 @@ const PhaseInput = ({ onUpdatePhase, phase, readOnly, phaseIndex }) => {
134139
135140PhaseInput . defaultProps = {
136141 endDate : null ,
137- readOnly : false
142+ readOnly : false ,
143+ isActive : false
138144}
139145
140146PhaseInput . propTypes = {
141147 phase : PropTypes . shape ( ) . isRequired ,
142148 onUpdatePhase : PropTypes . func . isRequired ,
143149 readOnly : PropTypes . bool ,
144- phaseIndex : PropTypes . string . isRequired
150+ phaseIndex : PropTypes . string . isRequired ,
151+ isActive : PropTypes . bool
145152}
146153export default PhaseInput
0 commit comments