@@ -103,7 +103,8 @@ class ChallengeEditor extends Component {
103103 // NOTE that we have to keep `assignedMemberDetails` in the local state, rather than just get it from the props
104104 // because we can update it locally when we choose another assigned user, so we don't have to wait for user details
105105 // to be loaded from Member Service as we already know it in such case
106- assignedMemberDetails : this . props . assignedMemberDetails
106+ assignedMemberDetails : this . props . assignedMemberDetails ,
107+ isPhaseChange : false
107108 }
108109 this . onUpdateInput = this . onUpdateInput . bind ( this )
109110 this . onUpdateSelect = this . onUpdateSelect . bind ( this )
@@ -865,8 +866,8 @@ class ChallengeEditor extends Component {
865866 . format ( 'MM/DD/YYYY HH:mm' )
866867 } else {
867868 newChallenge . phases [ index ] [ 'duration' ] = phase . duration
868- newChallenge . phases [ index ] [ 'scheduledStartDate' ] = phase . startDate
869- newChallenge . phases [ index ] [ 'scheduledEndDate' ] = phase . endDate
869+ newChallenge . phases [ index ] [ 'scheduledStartDate' ] = moment ( phase . startDate ) . toISOString ( )
870+ newChallenge . phases [ index ] [ 'scheduledEndDate' ] = moment ( phase . endDate ) . toISOString ( )
870871 }
871872
872873 for ( let phaseIndex = index + 1 ; phaseIndex < phases . length ; ++ phaseIndex ) {
@@ -886,7 +887,9 @@ class ChallengeEditor extends Component {
886887 . add ( newChallenge . phases [ phaseIndex ] [ 'duration' ] , 'hours' )
887888 . format ( 'MM/DD/YYYY HH:mm' )
888889 }
889-
890+ if ( ! _ . isEqual ( newChallenge . phases [ index ] , phases [ index ] ) ) {
891+ this . setState ( { isPhaseChange : true } )
892+ }
890893 this . setState ( { challenge : newChallenge } )
891894
892895 setTimeout ( ( ) => {
@@ -895,6 +898,7 @@ class ChallengeEditor extends Component {
895898 }
896899
897900 collectChallengeData ( status ) {
901+ const { isPhaseChange } = this . state
898902 const { attachments, metadata } = this . props
899903 const challenge = pick ( [
900904 'phases' ,
@@ -942,6 +946,7 @@ class ChallengeEditor extends Component {
942946 if ( challenge . terms && challenge . terms . length === 0 ) delete challenge . terms
943947 delete challenge . attachments
944948 delete challenge . reviewType
949+ if ( ! isPhaseChange ) delete challenge . phases
945950 return _ . cloneDeep ( challenge )
946951 }
947952
0 commit comments