@@ -15,7 +15,6 @@ import ChallengeTag from '../ChallengeTag'
1515import styles from './ChallengeCard.module.scss'
1616import { getFormattedDuration , formatDate } from '../../../util/date'
1717import { CHALLENGE_STATUS , COMMUNITY_APP_URL , DIRECT_PROJECT_URL , MESSAGE , ONLINE_REVIEW_URL } from '../../../config/constants'
18- import { patchChallenge } from '../../../services/challenges'
1918import ConfirmationModal from '../../Modal/ConfirmationModal'
2019import AlertModal from '../../Modal/AlertModal'
2120import Tooltip from '../../Tooltip'
@@ -201,12 +200,16 @@ class ChallengeCard extends React.Component {
201200 }
202201
203202 async onLaunchChallenge ( ) {
203+ const { partiallyUpdateChallengeDetails } = this . props
204204 if ( this . state . isSaving ) return
205205 const { challenge } = this . props
206206 try {
207207 this . setState ( { isSaving : true } )
208- const response = await patchChallenge ( challenge . id , { status : 'Active' } )
209- this . setState ( { isLaunch : true , isConfirm : response . id , isSaving : false } )
208+ // call action to update the challenge with a new status
209+ await partiallyUpdateChallengeDetails ( challenge . id , {
210+ status : 'Active'
211+ } )
212+ this . setState ( { isLaunch : true , isConfirm : challenge . id , isSaving : false } )
210213 } catch ( e ) {
211214 const error = _ . get ( e , 'response.data.message' , 'Unable to activate the challenge' )
212215 this . setState ( { isSaving : false , error } )
@@ -287,7 +290,8 @@ ChallengeCard.propTypes = {
287290 challenge : PropTypes . object ,
288291 shouldShowCurrentPhase : PropTypes . bool ,
289292 showError : PropTypes . func ,
290- reloadChallengeList : PropTypes . func
293+ reloadChallengeList : PropTypes . func ,
294+ partiallyUpdateChallengeDetails : PropTypes . func . isRequired
291295}
292296
293297export default withRouter ( ChallengeCard )
0 commit comments