Skip to content

Commit e153f32

Browse files
authored
Merge pull request #4589 from nursoltan-s/issue-4557-hotfix
fix submit page issue
2 parents 3c4c704 + 1837376 commit e153f32

File tree

1 file changed

+31
-10
lines changed

1 file changed

+31
-10
lines changed

src/shared/containers/SubmissionPage.jsx

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Passes the relevent state and setters as properties to the UI components.
88
*/
99
import actions from 'actions/page/submission';
10+
import { actions as api } from 'topcoder-react-lib';
1011
import { isMM } from 'utils/challenge';
1112
import communityActions from 'actions/tc-communities';
1213
import { PrimaryButton } from 'topcoder-react-ui-kit';
@@ -16,6 +17,7 @@ import PT from 'prop-types';
1617
import { connect } from 'react-redux';
1718
import SubmissionsPage from 'components/SubmissionPage';
1819
import AccessDenied, { CAUSE as ACCESS_DENIED_REASON } from 'components/tc-communities/AccessDenied';
20+
import LoadingIndicator from 'components/LoadingIndicator';
1921

2022
/**
2123
* SubmissionsPage Container
@@ -30,8 +32,15 @@ class SubmissionsPageContainer extends React.Component {
3032
const {
3133
auth,
3234
getCommunitiesList,
35+
challengeId,
36+
loadChallengeDetails,
37+
challengeName,
3338
} = this.props;
3439

40+
if (!challengeName) {
41+
loadChallengeDetails(auth, challengeId);
42+
}
43+
3544
getCommunitiesList(auth);
3645
}
3746

@@ -54,9 +63,14 @@ class SubmissionsPageContainer extends React.Component {
5463
const {
5564
isRegistered,
5665
challengeId,
66+
challengeName,
5767
} = this.props;
5868

59-
if (!isRegistered) {
69+
if (!challengeName) {
70+
return <LoadingIndicator />;
71+
}
72+
73+
if (!isRegistered && challengeName) {
6074
return (
6175
<React.Fragment>
6276
<AccessDenied cause={ACCESS_DENIED_REASON.NOT_AUTHORIZED}>
@@ -110,7 +124,7 @@ SubmissionsPageContainer.propTypes = {
110124
tokenV2: PT.string.isRequired,
111125
tokenV3: PT.string.isRequired,
112126
submit: PT.func.isRequired,
113-
challengeId: PT.number.isRequired,
127+
challengeId: PT.string.isRequired,
114128
track: PT.string.isRequired,
115129
challenge: PT.shape().isRequired,
116130
status: PT.string.isRequired,
@@ -139,6 +153,7 @@ SubmissionsPageContainer.propTypes = {
139153
setSubmissionFilestackData: PT.func.isRequired,
140154
submissionFilestackData: filestackDataProp.isRequired,
141155
winners: PT.arrayOf(PT.object).isRequired,
156+
loadChallengeDetails: PT.func.isRequired,
142157
};
143158

144159
/**
@@ -150,22 +165,23 @@ SubmissionsPageContainer.propTypes = {
150165
*/
151166
const mapStateToProps = (state, ownProps) => {
152167
const { submission } = state.page;
168+
const details = state.challenge.details || {};
153169
return {
154170
auth: state.auth,
155-
phases: state.challenge.details.phases || [],
171+
phases: details.phases || [],
156172
communitiesList: state.tcCommunities.list,
157173
/* Older stuff below. */
158174
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,
161177
challengesUrl: ownProps.challengesUrl,
162178
tokenV2: state.auth.tokenV2,
163179
tokenV3: state.auth.tokenV3,
164-
track: state.challenge.details.legacy.track,
180+
track: details.legacy ? details.legacy.track : '',
165181
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,
169185
isSubmitting: submission.isSubmitting,
170186
submitDone: submission.submitDone,
171187
errorMsg: submission.submitErrorMsg,
@@ -174,7 +190,7 @@ const mapStateToProps = (state, ownProps) => {
174190
filePickers: submission.filePickers,
175191
notesLength: submission.notesLength,
176192
submissionFilestackData: submission.submissionFilestackData,
177-
winners: state.challenge.details.winners,
193+
winners: details.winners,
178194
};
179195
};
180196

@@ -209,6 +225,11 @@ function mapDispatchToProps(dispatch) {
209225
setFilePickerUploadProgress: (id, p) => dispatch(a.setFilePickerUploadProgress(id, p)),
210226
updateNotesLength: length => dispatch(a.updateNotesLength(length)),
211227
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+
},
212233
};
213234
}
214235

0 commit comments

Comments
 (0)