@@ -96,20 +96,14 @@ const getPhaseInfo = (c) => {
9696 * @param onUpdateLaunch
9797 * @returns {* }
9898 */
99- const hoverComponents = ( challenge , onUpdateLaunch , deleteModalLaunch ) => {
99+ const hoverComponents = ( challenge , onUpdateLaunch ) => {
100100 const communityAppUrl = `${ COMMUNITY_APP_URL } /challenges/${ challenge . id } `
101101 const directUrl = `${ DIRECT_PROJECT_URL } /contest/detail?projectId=${ challenge . legacyId } `
102102 const orUrl = `${ ONLINE_REVIEW_URL } /review/actions/ViewProjectDetails?pid=${ challenge . legacyId } `
103103
104104 // NEW projects never have Legacy challenge created, so don't show links and "Activate" button for them at all
105105 if ( challenge . status . toUpperCase ( ) === CHALLENGE_STATUS . NEW ) {
106- if ( challenge . status . toUpperCase ( ) === CHALLENGE_STATUS . NEW ) {
107- return (
108- < button className = { styles . deleteButton } onClick = { deleteModalLaunch } >
109- < span > Delete</ span >
110- </ button >
111- )
112- }
106+ return null
113107 }
114108
115109 return challenge . legacyId ? (
@@ -183,13 +177,10 @@ class ChallengeCard extends React.Component {
183177 this . state = {
184178 isConfirm : false ,
185179 isLaunch : false ,
186- isDeleteLaunch : false ,
187180 isSaving : false
188181 }
189182 this . onUpdateConfirm = this . onUpdateConfirm . bind ( this )
190183 this . onUpdateLaunch = this . onUpdateLaunch . bind ( this )
191- this . onDeleteChallenge = this . onDeleteChallenge . bind ( this )
192- this . deleteModalLaunch = this . deleteModalLaunch . bind ( this )
193184 this . resetModal = this . resetModal . bind ( this )
194185 this . onLaunchChallenge = this . onLaunchChallenge . bind ( this )
195186 }
@@ -204,14 +195,8 @@ class ChallengeCard extends React.Component {
204195 }
205196 }
206197
207- deleteModalLaunch ( ) {
208- if ( ! this . state . isDeleteLaunch ) {
209- this . setState ( { isDeleteLaunch : true } )
210- }
211- }
212-
213198 resetModal ( ) {
214- this . setState ( { isConfirm : false , isLaunch : false , isDeleteLaunch : false } )
199+ this . setState ( { isConfirm : false , isLaunch : false } )
215200 }
216201
217202 async onLaunchChallenge ( ) {
@@ -236,39 +221,12 @@ class ChallengeCard extends React.Component {
236221 }
237222 }
238223
239- async onDeleteChallenge ( ) {
240- const { deleteChallenge, challenge } = this . props
241- try {
242- this . setState ( { isSaving : true } )
243- // Call action to delete the challenge
244- await deleteChallenge ( challenge . id )
245- this . setState ( { isSaving : false } )
246- this . resetModal ( )
247- } catch ( e ) {
248- const error = _ . get ( e , 'response.data.message' , 'Unable to Delete the challenge' )
249- this . setState ( { isSaving : false , error } )
250- }
251- }
252-
253224 render ( ) {
254- const { isLaunch, isConfirm, isSaving, isDeleteLaunch } = this . state
225+ const { isLaunch, isConfirm, isSaving } = this . state
255226 const { challenge, shouldShowCurrentPhase, reloadChallengeList } = this . props
256227 const { phaseMessage, endTime } = getPhaseInfo ( challenge )
257228 return (
258229 < div className = { styles . item } >
259- {
260- isDeleteLaunch && ! isConfirm && (
261- < ConfirmationModal
262- title = 'Confirm Delete'
263- message = { `Do you want to delete "${ challenge . name } "?` }
264- theme = { theme }
265- isProcessing = { isSaving }
266- errorMessage = { this . state . error }
267- onCancel = { this . resetModal }
268- onConfirm = { this . onDeleteChallenge }
269- />
270- )
271- }
272230 { isLaunch && ! isConfirm && (
273231 < ConfirmationModal
274232 title = 'Confirm Launch'
@@ -310,7 +268,7 @@ class ChallengeCard extends React.Component {
310268 < span className = 'block light-text' > { endTime } </ span >
311269 </ Link > ) }
312270 < div className = { cn ( styles . col4 , styles . editingContainer ) } >
313- { hoverComponents ( challenge , this . onUpdateLaunch , this . deleteModalLaunch ) }
271+ { hoverComponents ( challenge , this . onUpdateLaunch , this . props . showError ) }
314272 </ div >
315273 < div className = { cn ( styles . col4 , styles . iconsContainer ) } >
316274 < div className = { styles . faIconContainer } >
@@ -329,15 +287,16 @@ class ChallengeCard extends React.Component {
329287
330288ChallengeCard . defaultPrps = {
331289 shouldShowCurrentPhase : true ,
290+ showError : ( ) => { } ,
332291 reloadChallengeList : ( ) => { }
333292}
334293
335294ChallengeCard . propTypes = {
336295 challenge : PropTypes . object ,
337296 shouldShowCurrentPhase : PropTypes . bool ,
297+ showError : PropTypes . func ,
338298 reloadChallengeList : PropTypes . func ,
339- partiallyUpdateChallengeDetails : PropTypes . func . isRequired ,
340- deleteChallenge : PropTypes . func . isRequired
299+ partiallyUpdateChallengeDetails : PropTypes . func . isRequired
341300}
342301
343302export default withRouter ( ChallengeCard )
0 commit comments