Skip to content

Commit a573722

Browse files
committed
fix: change status on launch from details
ref issue #993
1 parent 4339ec1 commit a573722

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/actions/challenges.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,11 @@ export function partiallyUpdateChallengeDetails (challengeId, partialChallengeDe
258258
type: UPDATE_CHALLENGE_DETAILS_SUCCESS,
259259
challengeDetails: challenge
260260
})
261-
}).catch(() => {
261+
}).catch((error) => {
262262
dispatch({
263263
type: UPDATE_CHALLENGE_DETAILS_FAILURE
264264
})
265+
throw error
265266
})
266267
}
267268
}

src/containers/ChallengeEditor/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,21 +153,25 @@ class ChallengeEditor extends Component {
153153
}
154154

155155
async activateChallenge () {
156+
const { partiallyUpdateChallengeDetails } = this.props
156157
if (this.state.isLaunching) return
157158
const { challengeDetails } = this.props
158159
try {
159160
this.setState({ isLaunching: true })
160-
const response = await patchChallenge(challengeDetails.id, { status: 'Active' })
161+
// call action to update the challenge status
162+
const action = await partiallyUpdateChallengeDetails(challengeDetails.id, {
163+
status: 'Active'
164+
})
161165
this.setState({
162166
isLaunching: false,
163167
showLaunchModal: false,
164168
showSuccessModal: true,
165169
suceessMessage: MESSAGE.CHALLENGE_LAUNCH_SUCCESS,
166-
challengeDetails: { ...challengeDetails, status: response.status }
170+
challengeDetails: action.challengeDetails
167171
})
168172
} catch (e) {
169173
const error = _.get(e, 'response.data.message', 'Unable to activate the challenge')
170-
this.setState({ isLaunching: false, showLaunchModal: false, launchError: error })
174+
this.setState({ isLaunching: false, launchError: error })
171175
}
172176
}
173177

0 commit comments

Comments
 (0)