Skip to content

fix submit page issue #4589

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 31 additions & 10 deletions src/shared/containers/SubmissionPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Passes the relevent state and setters as properties to the UI components.
*/
import actions from 'actions/page/submission';
import { actions as api } from 'topcoder-react-lib';
import { isMM } from 'utils/challenge';
import communityActions from 'actions/tc-communities';
import { PrimaryButton } from 'topcoder-react-ui-kit';
Expand All @@ -16,6 +17,7 @@ import PT from 'prop-types';
import { connect } from 'react-redux';
import SubmissionsPage from 'components/SubmissionPage';
import AccessDenied, { CAUSE as ACCESS_DENIED_REASON } from 'components/tc-communities/AccessDenied';
import LoadingIndicator from 'components/LoadingIndicator';

/**
* SubmissionsPage Container
Expand All @@ -30,8 +32,15 @@ class SubmissionsPageContainer extends React.Component {
const {
auth,
getCommunitiesList,
challengeId,
loadChallengeDetails,
challengeName,
} = this.props;

if (!challengeName) {
loadChallengeDetails(auth, challengeId);
}

getCommunitiesList(auth);
}

Expand All @@ -54,9 +63,14 @@ class SubmissionsPageContainer extends React.Component {
const {
isRegistered,
challengeId,
challengeName,
} = this.props;

if (!isRegistered) {
if (!challengeName) {
return <LoadingIndicator />;
}

if (!isRegistered && challengeName) {
return (
<React.Fragment>
<AccessDenied cause={ACCESS_DENIED_REASON.NOT_AUTHORIZED}>
Expand Down Expand Up @@ -110,7 +124,7 @@ SubmissionsPageContainer.propTypes = {
tokenV2: PT.string.isRequired,
tokenV3: PT.string.isRequired,
submit: PT.func.isRequired,
challengeId: PT.number.isRequired,
challengeId: PT.string.isRequired,
track: PT.string.isRequired,
challenge: PT.shape().isRequired,
status: PT.string.isRequired,
Expand Down Expand Up @@ -139,6 +153,7 @@ SubmissionsPageContainer.propTypes = {
setSubmissionFilestackData: PT.func.isRequired,
submissionFilestackData: filestackDataProp.isRequired,
winners: PT.arrayOf(PT.object).isRequired,
loadChallengeDetails: PT.func.isRequired,
};

/**
Expand All @@ -150,22 +165,23 @@ SubmissionsPageContainer.propTypes = {
*/
const mapStateToProps = (state, ownProps) => {
const { submission } = state.page;
const details = state.challenge.details || {};
return {
auth: state.auth,
phases: state.challenge.details.phases || [],
phases: details.phases || [],
communitiesList: state.tcCommunities.list,
/* Older stuff below. */
userId: state.auth.user ? state.auth.user.userId : '',
challengeId: state.challenge.details.id,
challengeName: state.challenge.details.name,
challengeId: String(ownProps.match.params.challengeId),
challengeName: details.name,
challengesUrl: ownProps.challengesUrl,
tokenV2: state.auth.tokenV2,
tokenV3: state.auth.tokenV3,
track: state.challenge.details.legacy.track,
track: details.legacy ? details.legacy.track : '',
challenge: state.challenge,
status: state.challenge.details.status,
isRegistered: state.challenge.details.isRegistered,
groups: state.challenge.details.groups,
status: details.status,
isRegistered: details.isRegistered,
groups: details.groups,
isSubmitting: submission.isSubmitting,
submitDone: submission.submitDone,
errorMsg: submission.submitErrorMsg,
Expand All @@ -174,7 +190,7 @@ const mapStateToProps = (state, ownProps) => {
filePickers: submission.filePickers,
notesLength: submission.notesLength,
submissionFilestackData: submission.submissionFilestackData,
winners: state.challenge.details.winners,
winners: details.winners,
};
};

Expand Down Expand Up @@ -209,6 +225,11 @@ function mapDispatchToProps(dispatch) {
setFilePickerUploadProgress: (id, p) => dispatch(a.setFilePickerUploadProgress(id, p)),
updateNotesLength: length => dispatch(a.updateNotesLength(length)),
setSubmissionFilestackData: (id, data) => dispatch(a.setSubmissionFilestackData(id, data)),
loadChallengeDetails: (tokens, challengeId) => {
const challengeAction = api.challenge;
dispatch(challengeAction.getDetailsInit(challengeId));
dispatch(challengeAction.getDetailsDone(challengeId, tokens.tokenV3, tokens.tokenV2));
},
};
}

Expand Down