@@ -103,7 +103,8 @@ class ChallengeEditor extends Component {
103
103
// NOTE that we have to keep `assignedMemberDetails` in the local state, rather than just get it from the props
104
104
// because we can update it locally when we choose another assigned user, so we don't have to wait for user details
105
105
// 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
107
108
}
108
109
this . onUpdateInput = this . onUpdateInput . bind ( this )
109
110
this . onUpdateSelect = this . onUpdateSelect . bind ( this )
@@ -865,8 +866,8 @@ class ChallengeEditor extends Component {
865
866
. format ( 'MM/DD/YYYY HH:mm' )
866
867
} else {
867
868
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 ( )
870
871
}
871
872
872
873
for ( let phaseIndex = index + 1 ; phaseIndex < phases . length ; ++ phaseIndex ) {
@@ -886,7 +887,9 @@ class ChallengeEditor extends Component {
886
887
. add ( newChallenge . phases [ phaseIndex ] [ 'duration' ] , 'hours' )
887
888
. format ( 'MM/DD/YYYY HH:mm' )
888
889
}
889
-
890
+ if ( ! _ . isEqual ( newChallenge . phases [ index ] , phases [ index ] ) ) {
891
+ this . setState ( { isPhaseChange : true } )
892
+ }
890
893
this . setState ( { challenge : newChallenge } )
891
894
892
895
setTimeout ( ( ) => {
@@ -895,6 +898,7 @@ class ChallengeEditor extends Component {
895
898
}
896
899
897
900
collectChallengeData ( status ) {
901
+ const { isPhaseChange } = this . state
898
902
const { attachments, metadata } = this . props
899
903
const challenge = pick ( [
900
904
'phases' ,
@@ -942,6 +946,7 @@ class ChallengeEditor extends Component {
942
946
if ( challenge . terms && challenge . terms . length === 0 ) delete challenge . terms
943
947
delete challenge . attachments
944
948
delete challenge . reviewType
949
+ if ( ! isPhaseChange ) delete challenge . phases
945
950
return _ . cloneDeep ( challenge )
946
951
}
947
952
0 commit comments