@@ -96,20 +96,14 @@ const getPhaseInfo = (c) => {
96
96
* @param onUpdateLaunch
97
97
* @returns {* }
98
98
*/
99
- const hoverComponents = ( challenge , onUpdateLaunch , deleteModalLaunch ) => {
99
+ const hoverComponents = ( challenge , onUpdateLaunch ) => {
100
100
const communityAppUrl = `${ COMMUNITY_APP_URL } /challenges/${ challenge . id } `
101
101
const directUrl = `${ DIRECT_PROJECT_URL } /contest/detail?projectId=${ challenge . legacyId } `
102
102
const orUrl = `${ ONLINE_REVIEW_URL } /review/actions/ViewProjectDetails?pid=${ challenge . legacyId } `
103
103
104
104
// NEW projects never have Legacy challenge created, so don't show links and "Activate" button for them at all
105
105
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
113
107
}
114
108
115
109
return challenge . legacyId ? (
@@ -183,13 +177,10 @@ class ChallengeCard extends React.Component {
183
177
this . state = {
184
178
isConfirm : false ,
185
179
isLaunch : false ,
186
- isDeleteLaunch : false ,
187
180
isSaving : false
188
181
}
189
182
this . onUpdateConfirm = this . onUpdateConfirm . bind ( this )
190
183
this . onUpdateLaunch = this . onUpdateLaunch . bind ( this )
191
- this . onDeleteChallenge = this . onDeleteChallenge . bind ( this )
192
- this . deleteModalLaunch = this . deleteModalLaunch . bind ( this )
193
184
this . resetModal = this . resetModal . bind ( this )
194
185
this . onLaunchChallenge = this . onLaunchChallenge . bind ( this )
195
186
}
@@ -204,14 +195,8 @@ class ChallengeCard extends React.Component {
204
195
}
205
196
}
206
197
207
- deleteModalLaunch ( ) {
208
- if ( ! this . state . isDeleteLaunch ) {
209
- this . setState ( { isDeleteLaunch : true } )
210
- }
211
- }
212
-
213
198
resetModal ( ) {
214
- this . setState ( { isConfirm : false , isLaunch : false , isDeleteLaunch : false } )
199
+ this . setState ( { isConfirm : false , isLaunch : false } )
215
200
}
216
201
217
202
async onLaunchChallenge ( ) {
@@ -236,39 +221,12 @@ class ChallengeCard extends React.Component {
236
221
}
237
222
}
238
223
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
-
253
224
render ( ) {
254
- const { isLaunch, isConfirm, isSaving, isDeleteLaunch } = this . state
225
+ const { isLaunch, isConfirm, isSaving } = this . state
255
226
const { challenge, shouldShowCurrentPhase, reloadChallengeList } = this . props
256
227
const { phaseMessage, endTime } = getPhaseInfo ( challenge )
257
228
return (
258
229
< 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
- }
272
230
{ isLaunch && ! isConfirm && (
273
231
< ConfirmationModal
274
232
title = 'Confirm Launch'
@@ -310,7 +268,7 @@ class ChallengeCard extends React.Component {
310
268
< span className = 'block light-text' > { endTime } </ span >
311
269
</ Link > ) }
312
270
< div className = { cn ( styles . col4 , styles . editingContainer ) } >
313
- { hoverComponents ( challenge , this . onUpdateLaunch , this . deleteModalLaunch ) }
271
+ { hoverComponents ( challenge , this . onUpdateLaunch , this . props . showError ) }
314
272
</ div >
315
273
< div className = { cn ( styles . col4 , styles . iconsContainer ) } >
316
274
< div className = { styles . faIconContainer } >
@@ -329,15 +287,16 @@ class ChallengeCard extends React.Component {
329
287
330
288
ChallengeCard . defaultPrps = {
331
289
shouldShowCurrentPhase : true ,
290
+ showError : ( ) => { } ,
332
291
reloadChallengeList : ( ) => { }
333
292
}
334
293
335
294
ChallengeCard . propTypes = {
336
295
challenge : PropTypes . object ,
337
296
shouldShowCurrentPhase : PropTypes . bool ,
297
+ showError : PropTypes . func ,
338
298
reloadChallengeList : PropTypes . func ,
339
- partiallyUpdateChallengeDetails : PropTypes . func . isRequired ,
340
- deleteChallenge : PropTypes . func . isRequired
299
+ partiallyUpdateChallengeDetails : PropTypes . func . isRequired
341
300
}
342
301
343
302
export default withRouter ( ChallengeCard )
0 commit comments