Skip to content

Commit

Permalink
fix: change status on launch from details
Browse files Browse the repository at this point in the history
ref issue #993
  • Loading branch information
maxceem committed Dec 15, 2020
1 parent 4339ec1 commit a573722
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/actions/challenges.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,11 @@ export function partiallyUpdateChallengeDetails (challengeId, partialChallengeDe
type: UPDATE_CHALLENGE_DETAILS_SUCCESS,
challengeDetails: challenge
})
}).catch(() => {
}).catch((error) => {
dispatch({
type: UPDATE_CHALLENGE_DETAILS_FAILURE
})
throw error
})
}
}
Expand Down
10 changes: 7 additions & 3 deletions src/containers/ChallengeEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,21 +153,25 @@ class ChallengeEditor extends Component {
}

async activateChallenge () {
const { partiallyUpdateChallengeDetails } = this.props
if (this.state.isLaunching) return
const { challengeDetails } = this.props
try {
this.setState({ isLaunching: true })
const response = await patchChallenge(challengeDetails.id, { status: 'Active' })
// call action to update the challenge status
const action = await partiallyUpdateChallengeDetails(challengeDetails.id, {
status: 'Active'
})
this.setState({
isLaunching: false,
showLaunchModal: false,
showSuccessModal: true,
suceessMessage: MESSAGE.CHALLENGE_LAUNCH_SUCCESS,
challengeDetails: { ...challengeDetails, status: response.status }
challengeDetails: action.challengeDetails
})
} catch (e) {
const error = _.get(e, 'response.data.message', 'Unable to activate the challenge')
this.setState({ isLaunching: false, showLaunchModal: false, launchError: error })
this.setState({ isLaunching: false, launchError: error })
}
}

Expand Down

0 comments on commit a573722

Please sign in to comment.