@@ -19,6 +19,7 @@ import React from 'react';
19
19
import PT from 'prop-types' ;
20
20
import moment from 'moment' ;
21
21
import { PrimaryButton } from 'topcoder-react-ui-kit' ;
22
+ import { phaseEndDate } from 'utils/challenge-listing/helper' ;
22
23
import SubmissionsTable from '../SubmissionsTable' ;
23
24
24
25
import style from './styles.scss' ;
@@ -47,9 +48,11 @@ export default function SubmissionManagement(props) {
47
48
const currentPhase = challenge . phases
48
49
. filter ( p => p . name !== 'Registration' && p . isOpen )
49
50
. sort ( ( a , b ) => moment ( a . scheduledEndDate ) . diff ( b . scheduledEndDate ) ) [ 0 ] ;
51
+ const submissionPhase = challenge . phases . filter ( p => p . name === 'Submission' ) [ 0 ] ;
52
+ const submissionEndDate = submissionPhase && phaseEndDate ( submissionPhase ) ;
50
53
51
54
const now = moment ( ) ;
52
- const end = moment ( currentPhase . scheduledEndDate ) ;
55
+ const end = moment ( currentPhase && currentPhase . scheduledEndDate ) ;
53
56
const diff = end . isAfter ( now ) ? end . diff ( now ) : 0 ;
54
57
const timeLeft = moment . duration ( diff ) ;
55
58
@@ -78,11 +81,15 @@ export default function SubmissionManagement(props) {
78
81
</ a >
79
82
</ div >
80
83
< div styleName = "right-col" >
81
- < p styleName = "round" >
82
- { currentPhase . name }
83
- </ p >
84
84
{
85
- challenge . status !== 'COMPLETED' ? (
85
+ currentPhase && (
86
+ < p styleName = "round" >
87
+ { currentPhase . name }
88
+ </ p >
89
+ )
90
+ }
91
+ {
92
+ challenge . status !== 'Completed' ? (
86
93
< div >
87
94
< p styleName = "time-left" >
88
95
{ days > 0 && ( `${ days } D` ) }
@@ -111,7 +118,7 @@ export default function SubmissionManagement(props) {
111
118
Manage your submissions
112
119
</ p >
113
120
{
114
- isDesign && (
121
+ isDesign && currentPhase && (
115
122
< p styleName = "round-ends" >
116
123
< span styleName = "ends-label" >
117
124
{ currentPhase . name }
@@ -159,7 +166,7 @@ export default function SubmissionManagement(props) {
159
166
)
160
167
}
161
168
</ div >
162
- { now . isBefore ( challenge . submissionEndDate ) && (
169
+ { now . isBefore ( submissionEndDate ) && (
163
170
< div styleName = "btn-wrap" >
164
171
< PrimaryButton
165
172
theme = { {
0 commit comments