diff --git a/__tests__/shared/components/__snapshots__/Content.jsx.snap b/__tests__/shared/components/__snapshots__/Content.jsx.snap
index 659f2ce576..b40694e901 100644
--- a/__tests__/shared/components/__snapshots__/Content.jsx.snap
+++ b/__tests__/shared/components/__snapshots__/Content.jsx.snap
@@ -81,22 +81,17 @@ exports[`Matches shallow shapshot 1`] = `
topcoder-react-lib/src/services/api.js
- ), with support of TC authentication (look for auth tokens either in
-
- store.auth
-
-
- of Redux store, or in
-
- v3jwt
-
-
- and
-
- tcjwt
-
-
- cookies of the front-end requests to the server);
+ ), with support of TC authentication (look for auth tokens either in
+
+ store.auth
+
+
+ of Redux store, or in the
+
+ tcjwt
+
+
+ cookie of the front-end requests to the server);
diff --git a/src/shared/components/challenge-detail/MySubmissions/SubmissionsList/index.jsx b/src/shared/components/challenge-detail/MySubmissions/SubmissionsList/index.jsx
index 3a86b25541..a17e8b9133 100644
--- a/src/shared/components/challenge-detail/MySubmissions/SubmissionsList/index.jsx
+++ b/src/shared/components/challenge-detail/MySubmissions/SubmissionsList/index.jsx
@@ -63,6 +63,16 @@ const getDisplaySubmissionId = (submission) => {
return '';
};
+const getSubmissionCreatedTime = (submission) => {
+ if (!submission) return undefined;
+ return (
+ submission.created
+ || submission.createdAt
+ || submission.submissionTime
+ || submission.updated
+ || submission.updatedAt
+ );
+};
class SubmissionsListView extends React.Component {
constructor(props) {
@@ -73,7 +83,7 @@ class SubmissionsListView extends React.Component {
statusClicked: false,
finalClicked: false,
provisionClicked: false,
- timeClicked: false,
+ timeClicked: true,
openModal: false,
selectedSubmission: {},
};
@@ -106,7 +116,7 @@ class SubmissionsListView extends React.Component {
} = this.props;
let { field, sort } = submissionsSort;
if (!field) {
- field = 'Submission ID';
+ field = 'Time';
}
if (!sort) {
@@ -172,8 +182,8 @@ class SubmissionsListView extends React.Component {
break;
}
case 'Time': {
- valueA = new Date(a.submissionTime);
- valueB = new Date(b.submissionTime);
+ valueA = new Date(getSubmissionCreatedTime(a));
+ valueB = new Date(getSubmissionCreatedTime(b));
break;
}
default:
@@ -444,6 +454,10 @@ class SubmissionsListView extends React.Component {
const statusStyleName = isAccepted ? 'accepted' : 'queue';
const statusLabel = isAccepted ? 'Accepted' : 'In Queue';
const displaySubmissionId = getDisplaySubmissionId(mySubmission);
+ const submissionCreatedTime = getSubmissionCreatedTime(mySubmission);
+ const submissionTimeDisplay = submissionCreatedTime
+ ? moment(submissionCreatedTime).format('MMM DD, YYYY HH:mm:ss')
+ : 'N/A';
return (
Time
-
{moment(mySubmission.submissionTime).format('MMM DD, YYYY HH:mm:ss')}
+
{submissionTimeDisplay}
{ !isTopCrowdChallenge
diff --git a/src/shared/containers/challenge-detail/index.jsx b/src/shared/containers/challenge-detail/index.jsx
index 8ff11dc0ae..752f143028 100644
--- a/src/shared/containers/challenge-detail/index.jsx
+++ b/src/shared/containers/challenge-detail/index.jsx
@@ -179,8 +179,8 @@ class ChallengeDetailPageContainer extends React.Component {
sort: '',
},
mySubmissionsSort: {
- field: '',
- sort: '',
+ field: 'Time',
+ sort: 'desc',
},
notFoundCountryFlagUrl: {},
viewAsTable: false,
@@ -849,11 +849,43 @@ ChallengeDetailPageContainer.propTypes = {
getSubmissionArtifacts: PT.func,
};
+function extractArrayFromStateSlice(slice, challengeId) {
+ if (Array.isArray(slice)) {
+ return slice;
+ }
+ if (slice && Array.isArray(slice.data)) {
+ return slice.data;
+ }
+ const key = challengeId ? String(challengeId) : null;
+ if (key && slice && slice[key]) {
+ const scoped = slice[key];
+ if (Array.isArray(scoped)) {
+ return scoped;
+ }
+ if (scoped && Array.isArray(scoped.data)) {
+ return scoped.data;
+ }
+ }
+ return [];
+}
+
function mapStateToProps(state, props) {
+ const challengeId = String(props.match.params.challengeId);
const cl = state.challengeListing;
const { lookup: { allCountries, reviewTypes } } = state;
- let { challenge: { mmSubmissions } } = state;
+ const reviewSummations = extractArrayFromStateSlice(
+ state.challenge.reviewSummations,
+ challengeId,
+ );
+ let mmSubmissions = extractArrayFromStateSlice(state.challenge.mmSubmissions, challengeId);
+ if (!mmSubmissions.length && reviewSummations.length) {
+ mmSubmissions = buildMmSubmissionData(reviewSummations);
+ }
const { auth } = state;
+ let statisticsData = extractArrayFromStateSlice(state.challenge.statisticsData, challengeId);
+ if ((!Array.isArray(statisticsData) || !statisticsData.length) && reviewSummations.length) {
+ statisticsData = buildStatisticsData(reviewSummations);
+ }
const challenge = state.challenge.details || {};
let mySubmissions = [];
if (challenge.registrants) {
@@ -1087,7 +1119,7 @@ function mapStateToProps(state, props) {
// recommendedChallenges: cl.recommendedChallenges,
// loadingRecommendedChallengesUUID: cl.loadingRecommendedChallengesUUID,
expandedTags: cl.expandedTags,
- challengeId: String(props.match.params.challengeId),
+ challengeId,
challengesUrl: props.challengesUrl,
challengeTypesMap: state.challengeListing.challengeTypesMap,
checkpointResults: checkpoints.checkpointResults,
@@ -1099,7 +1131,7 @@ function mapStateToProps(state, props) {
isLoadingChallenge: Boolean(state.challenge.loadingDetailsForChallengeId),
isLoadingTerms: _.isEqual(state.terms.loadingTermsForEntity, {
type: 'challenge',
- id: props.match.params.challengeId,
+ id: challengeId,
}),
loadingCheckpointResults: state.challenge.loadingCheckpoints,
loadingResultsForChallengeId: state.challenge.loadingResultsForChallengeId,
@@ -1124,18 +1156,13 @@ function mapStateToProps(state, props) {
mySubmissions,
reviewTypes,
openForRegistrationChallenges: state.challengeListing.openForRegistrationChallenges,
- statisticsData: state.challenge.statisticsData,
+ statisticsData,
};
}
const mapDispatchToProps = (dispatch) => {
const ca = communityActions.tcCommunity;
const lookupActions = actions.lookup;
- const challengeActions = actions.challenge || {};
- const hasReviewSummationsActions = (
- typeof challengeActions.getReviewSummationsInit === 'function'
- && typeof challengeActions.getReviewSummationsDone === 'function'
- );
const dispatchReviewSummations = (challengeId, tokenV3) => {
const challengeIdStr = _.toString(challengeId);
@@ -1143,12 +1170,6 @@ const mapDispatchToProps = (dispatch) => {
return;
}
- if (hasReviewSummationsActions) {
- dispatch(challengeActions.getReviewSummationsInit(challengeIdStr));
- dispatch(challengeActions.getReviewSummationsDone(challengeIdStr, tokenV3));
- return;
- }
-
dispatch({
type: 'CHALLENGE/GET_REVIEW_SUMMATIONS_INIT',
payload: challengeIdStr,
diff --git a/src/shared/utils/tc.js b/src/shared/utils/tc.js
index 37cf139e44..0b1f3f3d79 100644
--- a/src/shared/utils/tc.js
+++ b/src/shared/utils/tc.js
@@ -200,7 +200,8 @@ export function getUnSelectedColors(rating) {
export function getAuthTokens(req = {}) {
const cookies = req.cookies || {};
let tokenV2 = cookies.tcjwt;
- let tokenV3 = cookies.v3jwt;
+ let tokenV3 = cookies.tcjwt;
+
if (!tokenV2 || isTokenExpired(tokenV2, config.AUTH_DROP_TIME)) {
tokenV2 = '';
}