7
7
* Passes the relevent state and setters as properties to the UI components.
8
8
*/
9
9
import actions from 'actions/page/submission' ;
10
+ import { actions as api } from 'topcoder-react-lib' ;
10
11
import { isMM } from 'utils/challenge' ;
11
12
import communityActions from 'actions/tc-communities' ;
12
13
import { PrimaryButton } from 'topcoder-react-ui-kit' ;
@@ -16,6 +17,7 @@ import PT from 'prop-types';
16
17
import { connect } from 'react-redux' ;
17
18
import SubmissionsPage from 'components/SubmissionPage' ;
18
19
import AccessDenied , { CAUSE as ACCESS_DENIED_REASON } from 'components/tc-communities/AccessDenied' ;
20
+ import LoadingIndicator from 'components/LoadingIndicator' ;
19
21
20
22
/**
21
23
* SubmissionsPage Container
@@ -30,8 +32,15 @@ class SubmissionsPageContainer extends React.Component {
30
32
const {
31
33
auth,
32
34
getCommunitiesList,
35
+ challengeId,
36
+ loadChallengeDetails,
37
+ challengeName,
33
38
} = this . props ;
34
39
40
+ if ( ! challengeName ) {
41
+ loadChallengeDetails ( auth , challengeId ) ;
42
+ }
43
+
35
44
getCommunitiesList ( auth ) ;
36
45
}
37
46
@@ -54,9 +63,14 @@ class SubmissionsPageContainer extends React.Component {
54
63
const {
55
64
isRegistered,
56
65
challengeId,
66
+ challengeName,
57
67
} = this . props ;
58
68
59
- if ( ! isRegistered ) {
69
+ if ( ! challengeName ) {
70
+ return < LoadingIndicator /> ;
71
+ }
72
+
73
+ if ( ! isRegistered && challengeName ) {
60
74
return (
61
75
< React . Fragment >
62
76
< AccessDenied cause = { ACCESS_DENIED_REASON . NOT_AUTHORIZED } >
@@ -110,7 +124,7 @@ SubmissionsPageContainer.propTypes = {
110
124
tokenV2 : PT . string . isRequired ,
111
125
tokenV3 : PT . string . isRequired ,
112
126
submit : PT . func . isRequired ,
113
- challengeId : PT . number . isRequired ,
127
+ challengeId : PT . string . isRequired ,
114
128
track : PT . string . isRequired ,
115
129
challenge : PT . shape ( ) . isRequired ,
116
130
status : PT . string . isRequired ,
@@ -139,6 +153,7 @@ SubmissionsPageContainer.propTypes = {
139
153
setSubmissionFilestackData : PT . func . isRequired ,
140
154
submissionFilestackData : filestackDataProp . isRequired ,
141
155
winners : PT . arrayOf ( PT . object ) . isRequired ,
156
+ loadChallengeDetails : PT . func . isRequired ,
142
157
} ;
143
158
144
159
/**
@@ -150,22 +165,23 @@ SubmissionsPageContainer.propTypes = {
150
165
*/
151
166
const mapStateToProps = ( state , ownProps ) => {
152
167
const { submission } = state . page ;
168
+ const details = state . challenge . details || { } ;
153
169
return {
154
170
auth : state . auth ,
155
- phases : state . challenge . details . phases || [ ] ,
171
+ phases : details . phases || [ ] ,
156
172
communitiesList : state . tcCommunities . list ,
157
173
/* Older stuff below. */
158
174
userId : state . auth . user ? state . auth . user . userId : '' ,
159
- challengeId : state . challenge . details . id ,
160
- challengeName : state . challenge . details . name ,
175
+ challengeId : String ( ownProps . match . params . challengeId ) ,
176
+ challengeName : details . name ,
161
177
challengesUrl : ownProps . challengesUrl ,
162
178
tokenV2 : state . auth . tokenV2 ,
163
179
tokenV3 : state . auth . tokenV3 ,
164
- track : state . challenge . details . legacy . track ,
180
+ track : details . legacy ? details . legacy . track : '' ,
165
181
challenge : state . challenge ,
166
- status : state . challenge . details . status ,
167
- isRegistered : state . challenge . details . isRegistered ,
168
- groups : state . challenge . details . groups ,
182
+ status : details . status ,
183
+ isRegistered : details . isRegistered ,
184
+ groups : details . groups ,
169
185
isSubmitting : submission . isSubmitting ,
170
186
submitDone : submission . submitDone ,
171
187
errorMsg : submission . submitErrorMsg ,
@@ -174,7 +190,7 @@ const mapStateToProps = (state, ownProps) => {
174
190
filePickers : submission . filePickers ,
175
191
notesLength : submission . notesLength ,
176
192
submissionFilestackData : submission . submissionFilestackData ,
177
- winners : state . challenge . details . winners ,
193
+ winners : details . winners ,
178
194
} ;
179
195
} ;
180
196
@@ -209,6 +225,11 @@ function mapDispatchToProps(dispatch) {
209
225
setFilePickerUploadProgress : ( id , p ) => dispatch ( a . setFilePickerUploadProgress ( id , p ) ) ,
210
226
updateNotesLength : length => dispatch ( a . updateNotesLength ( length ) ) ,
211
227
setSubmissionFilestackData : ( id , data ) => dispatch ( a . setSubmissionFilestackData ( id , data ) ) ,
228
+ loadChallengeDetails : ( tokens , challengeId ) => {
229
+ const challengeAction = api . challenge ;
230
+ dispatch ( challengeAction . getDetailsInit ( challengeId ) ) ;
231
+ dispatch ( challengeAction . getDetailsDone ( challengeId , tokens . tokenV3 , tokens . tokenV2 ) ) ;
232
+ } ,
212
233
} ;
213
234
}
214
235
0 commit comments