From dfeec86385980842e9b0b94036a722de3f38dbbf Mon Sep 17 00:00:00 2001 From: "Luiz R. Rodrigues" Date: Wed, 27 May 2020 13:39:11 -0300 Subject: [PATCH 01/12] update propTypes with new param in V5 API --- .../challenge-detail/Registrants/index.jsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/shared/components/challenge-detail/Registrants/index.jsx b/src/shared/components/challenge-detail/Registrants/index.jsx index fb9b4132c2..b35c0d0806 100644 --- a/src/shared/components/challenge-detail/Registrants/index.jsx +++ b/src/shared/components/challenge-detail/Registrants/index.jsx @@ -239,7 +239,7 @@ export default class Registrants extends React.Component { onSortChange, } = this.props; const { - prizes, + prizeSets, legacy, } = challenge; const { track } = legacy; @@ -247,14 +247,14 @@ export default class Registrants extends React.Component { const { field, sort } = this.getRegistrantsSortParam(); const revertSort = (sort === 'desc') ? 'asc' : 'desc'; const isDesign = track.toLowerCase() === 'design'; - const isF2F = challenge.subTrack.indexOf('FIRST_2_FINISH') > -1; - const isBugHunt = challenge.subTrack.indexOf('BUG_HUNT') > -1; + const isF2F = challenge.type.toLowerCase().indexOf('first2finish') > -1; + const isBugHunt = challenge.type.toLowerCase() === 'bug hunt'; const checkpoints = challenge.checkpoints || []; const twoRounds = challenge.round1Introduction && challenge.round2Introduction; - const places = prizes.length; + const places = prizeSets.find(ps => ps.type === 'Challenge Prize').prizes.lenght; return (
@@ -482,16 +482,16 @@ Registrants.propTypes = { challenge: PT.shape({ phases: PT.arrayOf(PT.shape({ actualEndDate: PT.string, - phaseType: PT.string.isRequired, + name: PT.string.isRequired, scheduledEndDate: PT.string, })).isRequired, allPhases: PT.arrayOf(PT.shape()), checkpoints: PT.arrayOf(PT.shape()), legacy: PT.shape({ - track: PT.any, + track: PT.string, }), - subTrack: PT.any, - prizes: PT.arrayOf(PT.number).isRequired, + type: PT.string, + prizeSets: PT.arrayOf(PT.shape()).isRequired, registrants: PT.arrayOf(PT.shape()).isRequired, round1Introduction: PT.string, round2Introduction: PT.string, From b9c25b0cbeb1e7b3e0c5f4b80ca319a459a52bc3 Mon Sep 17 00:00:00 2001 From: "Luiz R. Rodrigues" Date: Tue, 2 Jun 2020 13:46:39 -0300 Subject: [PATCH 02/12] Fix regex to challengeId (to support UUID) --- src/server/sw.js | 2 +- src/shared/reducers/index.js | 12 ++++++------ src/shared/reducers/reviewOpportunity.js | 4 ++-- src/shared/reducers/terms.js | 4 ++-- src/shared/routes/Communities/Comcast/Routes.jsx | 6 +++--- src/shared/routes/Topcoder/Routes.jsx | 6 +++--- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/server/sw.js b/src/server/sw.js index b51f364bb6..3a816790a7 100644 --- a/src/server/sw.js +++ b/src/server/sw.js @@ -87,7 +87,7 @@ workbox.routing.registerRoute(/\/challenges(\/)?(\?.*)?$/, async ({ event, url } }, 'GET'); // Serve challenge details pages like: /challenges/12345678 -workbox.routing.registerRoute(/\/challenges\/\d+(\/)?(.*)/, async ({ event, url }) => { +workbox.routing.registerRoute(/\/challenges\/([\w]{4,12}-?){5}(\/)?(.*)/, async ({ event, url }) => { if (url.pathname.endsWith('/')) { // Remove ending '/' char url.pathname = url.pathname.substring(0, url.pathname.length - 1); diff --git a/src/shared/reducers/index.js b/src/shared/reducers/index.js index 6b759c0c7c..695948ce11 100644 --- a/src/shared/reducers/index.js +++ b/src/shared/reducers/index.js @@ -45,12 +45,12 @@ function generateSsrOptions(req) { const res = { auth: getAuthTokens(req), }; - if (req.url.match(/^\/challenges\/\d+\/my-submissions/)) { - const challengeId = req.url.match(/\d+/)[0]; + if (req.url.match(/^\/challenges\/([\w]{4,12}-?){5}\/my-submissions/)) { + const challengeId = req.url.match(/([\w]{4,12}-?){5}/)[0]; _.set(res, 'challenge.challengeDetails.id', challengeId); _.set(res, 'challenge.challengeDetails.mySubmission', true); - } else if (req.url.match(/\/challenges\/\d+([?/].*)?$/)) { - const challengeId = req.url.match(/\d+/)[0]; + } else if (req.url.match(/\/challenges\/([\w]{4,12}-?){5}([?/].*)?$/)) { + const challengeId = req.url.match(/([\w]{4,12}-?){5}/)[0]; _.set(res, 'challenge.challengeDetails.id', challengeId); } @@ -62,8 +62,8 @@ function generateSsrOptions(req) { let entity; // if it's challenge details page - if (req.url.match(/^\/challenges\/\d+/)) { - const challengeId = req.url.match(/\d+/)[0]; + if (req.url.match(/^\/challenges\/([\w]{4,12}-?){5}/)) { + const challengeId = req.url.match(/([\w]{4,12}-?){5}/)[0]; entity = { type: 'challenge', id: challengeId }; } diff --git a/src/shared/reducers/reviewOpportunity.js b/src/shared/reducers/reviewOpportunity.js index 080b6614d4..5cf2a7f369 100644 --- a/src/shared/reducers/reviewOpportunity.js +++ b/src/shared/reducers/reviewOpportunity.js @@ -15,9 +15,9 @@ import { reducers } from 'topcoder-react-lib'; */ export function factory(req) { const options = {}; - if (req && req.url.match(/^\/challenges\/\d{8}\/review-opportunities/)) { + if (req && req.url.match(/^\/challenges\/([\w]{4,12}-?){5}\/review-opportunities/)) { options.auth = getAuthTokens(req); - const challengeId = req.url.match(/\d+/)[0]; + const challengeId = req.url.match(/([\w]{4,12}-?){5}/)[0]; _.set(options, 'reviewOpportunity.challenge.id', challengeId); } diff --git a/src/shared/reducers/terms.js b/src/shared/reducers/terms.js index 13c1f54a61..d8e0e6865c 100644 --- a/src/shared/reducers/terms.js +++ b/src/shared/reducers/terms.js @@ -322,8 +322,8 @@ export function factory(req) { let entity; // if it's challenge details page - if (req.url.match(/^\/challenges\/\d+/)) { - const challengeId = req.url.match(/\d+/)[0]; + if (req.url.match(/^\/challenges\/([\w]{4,12}-?){5}/)) { + const challengeId = req.url.match(/([\w]{4,12}-?){5}/)[0]; entity = { type: 'challenge', id: challengeId }; } diff --git a/src/shared/routes/Communities/Comcast/Routes.jsx b/src/shared/routes/Communities/Comcast/Routes.jsx index 63684d1ec6..2d8cb7a6e4 100644 --- a/src/shared/routes/Communities/Comcast/Routes.jsx +++ b/src/shared/routes/Communities/Comcast/Routes.jsx @@ -48,7 +48,7 @@ export default function CS({ base, meta }) { communityId: meta.communityId, })} exact - path={`${base}/work/:challengeId(\\d{8}|\\d{5})`} + path={`${base}/work/:challengeId((([\\w]{4,12}-?){5}))`} /> Submission({ @@ -56,7 +56,7 @@ export default function CS({ base, meta }) { challengesUrl: `${base}/work`, })} exact - path={`${base}/work/:challengeId(\\d{8}|\\d{5})/submit`} + path={`${base}/work/:challengeId((([\\w]{4,12}-?){5}))/submit`} /> SubmissionManagement({ @@ -64,7 +64,7 @@ export default function CS({ base, meta }) { challengesUrl: `${base}/work`, })} exact - path={`${base}/work/:challengeId(\\d{8}|\\d{5})/my-submissions`} + path={`${base}/work/:challengeId((([\\w]{4,12}-?){5}))/my-submissions`} /> - + Date: Tue, 2 Jun 2020 22:20:35 -0300 Subject: [PATCH 03/12] Update prizeSets.type from Challenge Prize to placement --- src/shared/components/challenge-detail/Registrants/index.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/components/challenge-detail/Registrants/index.jsx b/src/shared/components/challenge-detail/Registrants/index.jsx index b35c0d0806..838f4c2405 100644 --- a/src/shared/components/challenge-detail/Registrants/index.jsx +++ b/src/shared/components/challenge-detail/Registrants/index.jsx @@ -254,7 +254,7 @@ export default class Registrants extends React.Component { const twoRounds = challenge.round1Introduction && challenge.round2Introduction; - const places = prizeSets.find(ps => ps.type === 'Challenge Prize').prizes.lenght; + const places = prizeSets.find(ps => ps.type === 'placement').prizes.lenght; return (
From 4bd1737ea8818b300e1a5190f35beab20b616c22 Mon Sep 17 00:00:00 2001 From: "Luiz R. Rodrigues" Date: Wed, 3 Jun 2020 20:47:46 -0300 Subject: [PATCH 04/12] Updated URL params :challengeId to allow legacyID and UUID --- src/server/sw.js | 2 +- src/shared/reducers/index.js | 12 ++++++------ src/shared/reducers/reviewOpportunity.js | 4 ++-- src/shared/reducers/terms.js | 4 ++-- src/shared/routes/Communities/Comcast/Routes.jsx | 6 +++--- src/shared/routes/Topcoder/Routes.jsx | 6 +++--- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/server/sw.js b/src/server/sw.js index 3a816790a7..b3cbdbc6cf 100644 --- a/src/server/sw.js +++ b/src/server/sw.js @@ -87,7 +87,7 @@ workbox.routing.registerRoute(/\/challenges(\/)?(\?.*)?$/, async ({ event, url } }, 'GET'); // Serve challenge details pages like: /challenges/12345678 -workbox.routing.registerRoute(/\/challenges\/([\w]{4,12}-?){5}(\/)?(.*)/, async ({ event, url }) => { +workbox.routing.registerRoute(/\/challenges\/(([\w]{4,12}-?){5}|\d+)\/?(\?.*)?/, async ({ event, url }) => { if (url.pathname.endsWith('/')) { // Remove ending '/' char url.pathname = url.pathname.substring(0, url.pathname.length - 1); diff --git a/src/shared/reducers/index.js b/src/shared/reducers/index.js index 695948ce11..a84d236a80 100644 --- a/src/shared/reducers/index.js +++ b/src/shared/reducers/index.js @@ -45,12 +45,12 @@ function generateSsrOptions(req) { const res = { auth: getAuthTokens(req), }; - if (req.url.match(/^\/challenges\/([\w]{4,12}-?){5}\/my-submissions/)) { - const challengeId = req.url.match(/([\w]{4,12}-?){5}/)[0]; + if (req.url.match(/^\/challenges\/(([\w]{4,12}-?){5}|\d+)\/my-submissions/)) { + const challengeId = req.url.match(/(([\w]{4,12}-?){5}|\d+)/)[0]; _.set(res, 'challenge.challengeDetails.id', challengeId); _.set(res, 'challenge.challengeDetails.mySubmission', true); - } else if (req.url.match(/\/challenges\/([\w]{4,12}-?){5}([?/].*)?$/)) { - const challengeId = req.url.match(/([\w]{4,12}-?){5}/)[0]; + } else if (req.url.match(/\/challenges\/(([\w]{4,12}-?){5}|\d+)\/?(\?.*)?$/)) { + const challengeId = req.url.match(/(([\w]{4,12}-?){5}|\d+)/)[0]; _.set(res, 'challenge.challengeDetails.id', challengeId); } @@ -62,8 +62,8 @@ function generateSsrOptions(req) { let entity; // if it's challenge details page - if (req.url.match(/^\/challenges\/([\w]{4,12}-?){5}/)) { - const challengeId = req.url.match(/([\w]{4,12}-?){5}/)[0]; + if (req.url.match(/^\/challenges\/(([\w]{4,12}-?){5}|\d+)/)) { + const challengeId = req.url.match(/(([\w]{4,12}-?){5}|\d+)/)[0]; entity = { type: 'challenge', id: challengeId }; } diff --git a/src/shared/reducers/reviewOpportunity.js b/src/shared/reducers/reviewOpportunity.js index 5cf2a7f369..2bdd61235a 100644 --- a/src/shared/reducers/reviewOpportunity.js +++ b/src/shared/reducers/reviewOpportunity.js @@ -15,9 +15,9 @@ import { reducers } from 'topcoder-react-lib'; */ export function factory(req) { const options = {}; - if (req && req.url.match(/^\/challenges\/([\w]{4,12}-?){5}\/review-opportunities/)) { + if (req && req.url.match(/^\/challenges\/(([\w]{4,12}-?){5}|\d+)\/review-opportunities/)) { options.auth = getAuthTokens(req); - const challengeId = req.url.match(/([\w]{4,12}-?){5}/)[0]; + const challengeId = req.url.match(/(([\w]{4,12}-?){5}|\d+)/)[0]; _.set(options, 'reviewOpportunity.challenge.id', challengeId); } diff --git a/src/shared/reducers/terms.js b/src/shared/reducers/terms.js index d8e0e6865c..463610a28e 100644 --- a/src/shared/reducers/terms.js +++ b/src/shared/reducers/terms.js @@ -322,8 +322,8 @@ export function factory(req) { let entity; // if it's challenge details page - if (req.url.match(/^\/challenges\/([\w]{4,12}-?){5}/)) { - const challengeId = req.url.match(/([\w]{4,12}-?){5}/)[0]; + if (req.url.match(/^\/challenges\/(([\w]{4,12}-?){5}|\d+)/)) { + const challengeId = req.url.match(/(([\w]{4,12}-?){5}|\d+)/)[0]; entity = { type: 'challenge', id: challengeId }; } diff --git a/src/shared/routes/Communities/Comcast/Routes.jsx b/src/shared/routes/Communities/Comcast/Routes.jsx index 2d8cb7a6e4..0ff445ff3a 100644 --- a/src/shared/routes/Communities/Comcast/Routes.jsx +++ b/src/shared/routes/Communities/Comcast/Routes.jsx @@ -48,7 +48,7 @@ export default function CS({ base, meta }) { communityId: meta.communityId, })} exact - path={`${base}/work/:challengeId((([\\w]{4,12}-?){5}))`} + path={`${base}/work/:challengeId(((([\\w]{4,12}-?){5}|\\d+)))`} /> Submission({ @@ -56,7 +56,7 @@ export default function CS({ base, meta }) { challengesUrl: `${base}/work`, })} exact - path={`${base}/work/:challengeId((([\\w]{4,12}-?){5}))/submit`} + path={`${base}/work/:challengeId(((([\\w]{4,12}-?){5}|\\d+)))/submit`} /> SubmissionManagement({ @@ -64,7 +64,7 @@ export default function CS({ base, meta }) { challengesUrl: `${base}/work`, })} exact - path={`${base}/work/:challengeId((([\\w]{4,12}-?){5}))/my-submissions`} + path={`${base}/work/:challengeId(((([\\w]{4,12}-?){5}|\\d+))/my-submissions`} /> - + Date: Wed, 3 Jun 2020 22:44:50 -0300 Subject: [PATCH 05/12] Added validation if receive challenge tags before get recommendedChallenges --- src/shared/containers/challenge-detail/index.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/shared/containers/challenge-detail/index.jsx b/src/shared/containers/challenge-detail/index.jsx index 2c72e5378c..242440ce7d 100644 --- a/src/shared/containers/challenge-detail/index.jsx +++ b/src/shared/containers/challenge-detail/index.jsx @@ -225,6 +225,7 @@ class ChallengeDetailPageContainer extends React.Component { challenge && challenge.id === challengeId && !loadingRecommendedChallengesUUID + && recommendedTechnology && ( !recommendedChallenges[recommendedTechnology] || ( From 6acb8ef14af3e554b45b9ff3e2a3cb35cf217f3d Mon Sep 17 00:00:00 2001 From: "Luiz R. Rodrigues" Date: Thu, 4 Jun 2020 00:35:36 -0300 Subject: [PATCH 06/12] Update vars to match with V5 API --- .../Header/TabSelector/index.jsx | 20 ++++++------- .../challenge-detail/Header/index.jsx | 12 ++++---- .../challenge-detail/Registrants/index.jsx | 30 +++++++++---------- .../challenge-detail/Submissions/index.jsx | 6 ++-- 4 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/shared/components/challenge-detail/Header/TabSelector/index.jsx b/src/shared/components/challenge-detail/Header/TabSelector/index.jsx index 7049280fd2..1c7d20c74e 100644 --- a/src/shared/components/challenge-detail/Header/TabSelector/index.jsx +++ b/src/shared/components/challenge-detail/Header/TabSelector/index.jsx @@ -21,8 +21,8 @@ export default function ChallengeViewSelector(props) { const { challenge, checkpointCount, - numRegistrants, - numSubmissions, + numOfRegistrants, + numOfSubmissions, numWinners, onSelectorClicked, selectedView, @@ -86,7 +86,7 @@ export default function ChallengeViewSelector(props) { DETAILS { - numRegistrants ? ( + numOfRegistrants ? ( REGISTRANTS ( - {numRegistrants} + {numOfRegistrants} ) ) : null @@ -123,7 +123,7 @@ export default function ChallengeViewSelector(props) { ) } { - numSubmissions ? ( + numOfSubmissions ? ( SUBMISSIONS ( - {numSubmissions} + {numOfSubmissions} ) ) : null @@ -188,8 +188,8 @@ export default function ChallengeViewSelector(props) { ChallengeViewSelector.defaultProps = { challenge: {}, checkpointCount: 0, - numRegistrants: 0, - numSubmissions: 0, + numOfRegistrants: 0, + numOfSubmissions: 0, // hasRegistered: false, }; @@ -204,8 +204,8 @@ ChallengeViewSelector.propTypes = { }), }), checkpointCount: PT.number, - numRegistrants: PT.number, - numSubmissions: PT.number, + numOfRegistrants: PT.number, + numOfSubmissions: PT.number, numWinners: PT.number.isRequired, onSelectorClicked: PT.func.isRequired, selectedView: PT.string.isRequired, diff --git a/src/shared/components/challenge-detail/Header/index.jsx b/src/shared/components/challenge-detail/Header/index.jsx index c0af7e6097..01ee27cefb 100644 --- a/src/shared/components/challenge-detail/Header/index.jsx +++ b/src/shared/components/challenge-detail/Header/index.jsx @@ -70,8 +70,8 @@ export default function ChallengeHeader(props) { topCheckPointPrize, reliabilityBonus, userDetails, - numRegistrants, - numSubmissions, + numOfRegistrants, + numOfSubmissions, appealsEndDate, } = challenge; @@ -445,10 +445,10 @@ export default function ChallengeHeader(props) { onSelectorClicked={onSelectorClicked} trackLower={trackLower} selectedView={selectedView} - numRegistrants={numRegistrants} + numOfRegistrants={numOfRegistrants} numWinners={numWinners} hasCheckpoints={checkpoints && checkpoints.length > 0} - numSubmissions={numSubmissions} + numOfSubmissions={numOfSubmissions} hasRegistered={hasRegistered} checkpointCount={checkpointCount} mySubmissions={mySubmissions} @@ -488,8 +488,8 @@ ChallengeHeader.propTypes = { reliabilityBonus: PT.any, userDetails: PT.any, currentPhases: PT.any, - numRegistrants: PT.any, - numSubmissions: PT.any, + numOfRegistrants: PT.any, + numOfSubmissions: PT.any, status: PT.any, appealsEndDate: PT.any, allPhases: PT.any, diff --git a/src/shared/components/challenge-detail/Registrants/index.jsx b/src/shared/components/challenge-detail/Registrants/index.jsx index 838f4c2405..078c8fa43e 100644 --- a/src/shared/components/challenge-detail/Registrants/index.jsx +++ b/src/shared/components/challenge-detail/Registrants/index.jsx @@ -19,20 +19,20 @@ function formatDate(date) { return moment(date).format('MMM DD, YYYY HH:mm'); } -function getDate(arr, handle) { - const results = arr.filter(a => _.toString(a.submitter || a.handle) === _.toString(handle)) +function getDate(arr, memberHandle) { + const results = arr.filter(a => _.toString(a.submitter || a.memberHandle) === _.toString(memberHandle)) .sort((a, b) => new Date(b.submissionTime || b.submissionDate).getTime() - new Date(a.submissionTime || a.submissionDate).getTime()); return results[0] ? (results[0].submissionTime || results[0].submissionDate) : ''; } -function passedCheckpoint(checkpoints, handle, results) { - const mine = checkpoints.filter(c => _.toString(c.submitter) === _.toString(handle)); +function passedCheckpoint(checkpoints, memberHandle, results) { + const mine = checkpoints.filter(c => _.toString(c.submitter) === _.toString(memberHandle)); return _.some(mine, m => _.find(results, r => r.submissionId === m.submissionId)); } -function getPlace(results, handle, places) { - const found = _.find(results, w => _.toString(w.handle) === _.toString(handle) +function getPlace(results, memberHandle, places) { + const found = _.find(results, w => _.toString(w.memberHandle) === _.toString(memberHandle) && w.placement <= places && w.submissionStatus !== 'Failed Review'); if (found) { @@ -99,7 +99,7 @@ export default class Registrants extends React.Component { let checkpoint; if (twoRounds) { - checkpoint = getDate(checkpoints, registrant.handle); + checkpoint = getDate(checkpoints, registrant.memberHandle); if (!checkpoint && moment(registrant.submissionDate).isBefore(checkpointDate)) { checkpoint = registrant.submissionDate; @@ -188,8 +188,8 @@ export default class Registrants extends React.Component { break; } case 'Username': { - valueA = `${a.handle}`.toLowerCase(); - valueB = `${b.handle}`.toLowerCase(); + valueA = `${a.memberHandle}`.toLowerCase(); + valueB = `${b.memberHandle}`.toLowerCase(); valueIsString = true; break; } @@ -379,7 +379,7 @@ export default class Registrants extends React.Component {
{ sortedRegistrants.map((r) => { - const placement = getPlace(results, r.handle, places); + const placement = getPlace(results, r.memberHandle, places); const colorStyle = JSON.parse(r.colorStyle.replace(/(\w+):\s*([^;]*)/g, '{"$1": "$2"}')); let checkpoint = this.getCheckPoint(r); if (checkpoint) { @@ -393,7 +393,7 @@ export default class Registrants extends React.Component { } return ( -
+
{ !isDesign && !isF2F && !isBugHunt && (
@@ -411,11 +411,11 @@ export default class Registrants extends React.Component { @@ -423,7 +423,7 @@ export default class Registrants extends React.Component {
Registration Date
- {formatDate(r.registrationDate)} + {formatDate(r.created)}
{ twoRounds @@ -437,7 +437,7 @@ export default class Registrants extends React.Component { {checkpoint} { - passedCheckpoint(checkpoints, r.handle, checkpointResults) + passedCheckpoint(checkpoints, r.memberHandle, checkpointResults) && }
diff --git a/src/shared/components/challenge-detail/Submissions/index.jsx b/src/shared/components/challenge-detail/Submissions/index.jsx index ee1abe9df8..bc5adfcd7e 100644 --- a/src/shared/components/challenge-detail/Submissions/index.jsx +++ b/src/shared/components/challenge-detail/Submissions/index.jsx @@ -327,8 +327,8 @@ class SubmissionsComponent extends React.Component {
); - const isF2F = challenge.subTrack.indexOf('FIRST_2_FINISH') > -1; - const isBugHunt = challenge.subTrack.indexOf('BUG_HUNT') > -1; + const isF2F = challenge.type.toLowerCase().indexOf('first2finish') > -1; + const isBugHunt = challenge.type.toLowerCase() === 'bug hunt'; // copy colorStyle from registrants to submissions _.forEach(sortedSubmissions, (s) => { @@ -785,7 +785,7 @@ SubmissionsComponent.propTypes = { registrants: PT.any, allPhases: PT.any, phases: PT.any, - subTrack: PT.any, + type: PT.any, }).isRequired, toggleSubmissionHistory: PT.func.isRequired, submissionHistoryOpen: PT.shape({}).isRequired, From 28e4c44ae5d4441a3c5156e7f88eb6d95f8308f9 Mon Sep 17 00:00:00 2001 From: "Luiz R. Rodrigues" Date: Thu, 4 Jun 2020 01:07:17 -0300 Subject: [PATCH 07/12] Fix lint --- .../challenge-detail/Registrants/index.jsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/shared/components/challenge-detail/Registrants/index.jsx b/src/shared/components/challenge-detail/Registrants/index.jsx index 078c8fa43e..fe468d4222 100644 --- a/src/shared/components/challenge-detail/Registrants/index.jsx +++ b/src/shared/components/challenge-detail/Registrants/index.jsx @@ -19,20 +19,20 @@ function formatDate(date) { return moment(date).format('MMM DD, YYYY HH:mm'); } -function getDate(arr, memberHandle) { - const results = arr.filter(a => _.toString(a.submitter || a.memberHandle) === _.toString(memberHandle)) +function getDate(arr, handle) { + const results = arr.filter(a => _.toString(a.submitter || a.memberHandle) === _.toString(handle)) .sort((a, b) => new Date(b.submissionTime || b.submissionDate).getTime() - new Date(a.submissionTime || a.submissionDate).getTime()); return results[0] ? (results[0].submissionTime || results[0].submissionDate) : ''; } -function passedCheckpoint(checkpoints, memberHandle, results) { - const mine = checkpoints.filter(c => _.toString(c.submitter) === _.toString(memberHandle)); +function passedCheckpoint(checkpoints, handle, results) { + const mine = checkpoints.filter(c => _.toString(c.submitter) === _.toString(handle)); return _.some(mine, m => _.find(results, r => r.submissionId === m.submissionId)); } -function getPlace(results, memberHandle, places) { - const found = _.find(results, w => _.toString(w.memberHandle) === _.toString(memberHandle) +function getPlace(results, handle, places) { + const found = _.find(results, w => _.toString(w.memberHandle) === _.toString(handle) && w.placement <= places && w.submissionStatus !== 'Failed Review'); if (found) { From 6a533fa298ad33f84e45daa538f24e88b93ca6d4 Mon Sep 17 00:00:00 2001 From: rashmi73 <41687423+rashmi73@users.noreply.github.com> Date: Sun, 7 Jun 2020 22:49:23 +0530 Subject: [PATCH 08/12] Update index.jsx --- .../components/challenge-detail/Specification/SideBar/index.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/components/challenge-detail/Specification/SideBar/index.jsx b/src/shared/components/challenge-detail/Specification/SideBar/index.jsx index 0ace088c75..4602d9602b 100644 --- a/src/shared/components/challenge-detail/Specification/SideBar/index.jsx +++ b/src/shared/components/challenge-detail/Specification/SideBar/index.jsx @@ -36,7 +36,7 @@ export default function SideBar({ const faqURL = config.URL.INFO.DESIGN_CHALLENGE_SUBMISSION; let submissionLimitDisplay = 'Unlimited'; const submissionLimit = _.find(metadata, { type: 'submissionLimit' }); - const fileTypes = _.find(metadata, { type: 'fileTypes' }); + const fileTypes = _.find(metadata, { name: 'fileTypes' }); if (submissionLimit) { if (submissionLimit.value === 1) { From 6f21672097b8dde17cca989cb9aed1815e7a9c8b Mon Sep 17 00:00:00 2001 From: "Luiz R. Rodrigues" Date: Sun, 7 Jun 2020 21:37:10 -0300 Subject: [PATCH 09/12] Added default colorStyle to all members (temp solution) --- .../components/challenge-detail/Registrants/index.jsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/shared/components/challenge-detail/Registrants/index.jsx b/src/shared/components/challenge-detail/Registrants/index.jsx index fe468d4222..061aab9319 100644 --- a/src/shared/components/challenge-detail/Registrants/index.jsx +++ b/src/shared/components/challenge-detail/Registrants/index.jsx @@ -380,7 +380,13 @@ export default class Registrants extends React.Component { { sortedRegistrants.map((r) => { const placement = getPlace(results, r.memberHandle, places); - const colorStyle = JSON.parse(r.colorStyle.replace(/(\w+):\s*([^;]*)/g, '{"$1": "$2"}')); + /* + * TODO: Need check as get this back, currenlty V5 API missing this data + * = JSON.parse(r.colorStyle.replace(/(\w+):\s*([^;]*)/g, '{"$1": "$2"}')); + */ + const colorStyle = { + color: '#000000', + }; let checkpoint = this.getCheckPoint(r); if (checkpoint) { checkpoint = formatDate(checkpoint); From f75b3d4ae8a36f93d28fd72109e1ae2c96e10365 Mon Sep 17 00:00:00 2001 From: "Luiz R. Rodrigues" Date: Sun, 7 Jun 2020 21:38:05 -0300 Subject: [PATCH 10/12] Reactivated the proxy-get to support calls to resources_api --- src/server/index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/server/index.js b/src/server/index.js index 062cb1449c..59fb521c59 100644 --- a/src/server/index.js +++ b/src/server/index.js @@ -9,7 +9,7 @@ import Application from 'shared'; import config from 'config'; import express from 'express'; import fetch from 'isomorphic-fetch'; -import { logger } from 'topcoder-react-lib'; +import { logger, services } from 'topcoder-react-lib'; import fs from 'fs'; import moment from 'moment'; import path from 'path'; @@ -160,11 +160,14 @@ async function onExpressJsSetup(server) { /* Proxy endpoint for GET requests (to fetch data from resources prohibiting * cross-origin requests). */ - /* server.use( + server.use( '/community-app-assets/api/proxy-get', checkAuthorizationHeader, async (req, res, next) => { + const tokenM2M = await services.api.getTcM2mToken(); try { - let data = await fetch(req.query.url); + let data = await fetch(req.query.url, { + headers: { Authorization: `Bearer ${tokenM2M}` }, + }); data = await data.text(); res.send(data); } catch (err) { @@ -172,7 +175,6 @@ async function onExpressJsSetup(server) { } }, ); - */ /* Proxy endpoint for POST requests (to fetch data from resources prohibiting * cross-origin requests). */ From 16b58963e85239ca4792596436c28b6528104afc Mon Sep 17 00:00:00 2001 From: "Luiz R. Rodrigues" Date: Sun, 7 Jun 2020 23:06:06 -0300 Subject: [PATCH 11/12] Challenge listing - Added check if challenge.events is empty --- .../RecommendedActiveChallenges/ChallengesCard/index.jsx | 2 +- src/shared/components/challenge-listing/ChallengeCard/index.jsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/shared/components/challenge-detail/RecommendedActiveChallenges/ChallengesCard/index.jsx b/src/shared/components/challenge-detail/RecommendedActiveChallenges/ChallengesCard/index.jsx index e97b81ded6..be9b540922 100644 --- a/src/shared/components/challenge-detail/RecommendedActiveChallenges/ChallengesCard/index.jsx +++ b/src/shared/components/challenge-detail/RecommendedActiveChallenges/ChallengesCard/index.jsx @@ -65,7 +65,7 @@ export default function ChallengesCard({ diff --git a/src/shared/components/challenge-listing/ChallengeCard/index.jsx b/src/shared/components/challenge-listing/ChallengeCard/index.jsx index 6168ba6e87..ee4f5f0c29 100644 --- a/src/shared/components/challenge-listing/ChallengeCard/index.jsx +++ b/src/shared/components/challenge-listing/ChallengeCard/index.jsx @@ -74,7 +74,7 @@ function ChallengeCard({ From e36c4c45752bb56041b23217bf2245d4a143cdbc Mon Sep 17 00:00:00 2001 From: "Luiz R. Rodrigues" Date: Mon, 8 Jun 2020 00:56:04 -0300 Subject: [PATCH 12/12] Challenge Details - Fix isRegistered function --- src/shared/containers/challenge-detail/index.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/shared/containers/challenge-detail/index.jsx b/src/shared/containers/challenge-detail/index.jsx index 242440ce7d..aac0067734 100644 --- a/src/shared/containers/challenge-detail/index.jsx +++ b/src/shared/containers/challenge-detail/index.jsx @@ -116,7 +116,7 @@ function isRegistered(details, registrants, handle) { if (details && details.roles && details.roles.includes('Submitter')) { return true; } - if (_.find(registrants, r => _.toString(r.handle) === _.toString(handle))) { + if (_.find(registrants, r => _.toString(r.memberHandle) === _.toString(handle))) { return true; } return false; @@ -726,7 +726,7 @@ function mapStateToProps(state, props) { if (challenge.submissions) { challenge.submissions = challenge.submissions.map(submission => ({ ...submission, - registrant: _.find(challenge.registrants, { handle: submission.submitter }), + registrant: _.find(challenge.registrants, { memberHandle: submission.createdBy }), })); } @@ -734,7 +734,7 @@ function mapStateToProps(state, props) { mmSubmissions = mmSubmissions.map((submission) => { let registrant; let { member } = submission; - if (auth.user.handle === submission.member) { + if (auth.user.handle === submission.memberHandle) { mySubmissions = submission.submissions || []; mySubmissions = mySubmissions.map((mySubmission, index) => { // eslint-disable-next-line no-param-reassign