From d753a139cc96b47fbf3daab7ca72263cf50886f0 Mon Sep 17 00:00:00 2001 From: sr_jr Date: Sun, 7 Jun 2020 13:04:32 +0530 Subject: [PATCH 1/2] fix for issue #4384 --- .../ChallengeCard/Status/index.jsx | 14 ++++---------- .../challenge-listing/ChallengeCard/index.jsx | 8 ++++---- .../challenge-listing/Listing/Bucket/index.jsx | 8 ++++---- .../components/challenge-listing/Listing/index.jsx | 4 ++-- 4 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/shared/components/challenge-listing/ChallengeCard/Status/index.jsx b/src/shared/components/challenge-listing/ChallengeCard/Status/index.jsx index 025cb0656d..39160ca49b 100644 --- a/src/shared/components/challenge-listing/ChallengeCard/Status/index.jsx +++ b/src/shared/components/challenge-listing/ChallengeCard/Status/index.jsx @@ -60,6 +60,7 @@ export default function ChallengeStatus(props) { newChallengeDetails, selectChallengeDetailsTab, openChallengesInNewTabs, + userId, } = props; /* TODO: Split into a separate ReactJS component! */ @@ -218,20 +219,11 @@ export default function ChallengeStatus(props) { statusPhase.name = 'Submission'; } - const registrationPhase = allPhases - .find(p => p.name === 'Registration'); - const isRegistrationOpen = registrationPhase - && ( - registrationPhase.isOpen - || moment(registrationPhase.scheduledEndDate).diff(new Date()) > 0); - - let phaseMessage = STALLED_MSG; if (statusPhase) phaseMessage = statusPhase.name; else if (status === 'Draft') phaseMessage = DRAFT_MSG; - // TODO: Find equivalent of !challenge.users[userHandle] - const showRegisterInfo = isRegistrationOpen; + const showRegisterInfo = challenge.registrationOpen == 'Yes' && !challenge.users[userId]; return (
@@ -304,6 +296,7 @@ ChallengeStatus.defaultProps = { detailLink: '', openChallengesInNewTabs: false, className: '', + userId: '', }; ChallengeStatus.propTypes = { @@ -314,4 +307,5 @@ ChallengeStatus.propTypes = { openChallengesInNewTabs: PT.bool, // eslint-disable-line react/no-unused-prop-types selectChallengeDetailsTab: PT.func.isRequired, className: PT.string, + userId: PT.string, }; diff --git a/src/shared/components/challenge-listing/ChallengeCard/index.jsx b/src/shared/components/challenge-listing/ChallengeCard/index.jsx index c67373eb49..7e3da661a0 100644 --- a/src/shared/components/challenge-listing/ChallengeCard/index.jsx +++ b/src/shared/components/challenge-listing/ChallengeCard/index.jsx @@ -33,7 +33,7 @@ function ChallengeCard({ openChallengesInNewTabs, sampleWinnerProfile, selectChallengeDetailsTab, - userHandle, + userId, domRef, }) { const challenge = passedInChallenge; @@ -116,7 +116,7 @@ function ChallengeCard({ openChallengesInNewTabs={openChallengesInNewTabs} sampleWinnerProfile={sampleWinnerProfile} selectChallengeDetailsTab={selectChallengeDetailsTab} - userHandle={userHandle} + userId={userId} />
@@ -130,7 +130,7 @@ ChallengeCard.defaultProps = { onTechTagClicked: _.noop, openChallengesInNewTabs: false, sampleWinnerProfile: undefined, - userHandle: '', + userId: '', expandedTags: [], expandTag: null, domRef: null, @@ -145,7 +145,7 @@ ChallengeCard.propTypes = { openChallengesInNewTabs: PT.bool, sampleWinnerProfile: PT.shape(), selectChallengeDetailsTab: PT.func.isRequired, - userHandle: PT.string, + userId: PT.string, expandedTags: PT.arrayOf(PT.number), expandTag: PT.func, domRef: PT.func, diff --git a/src/shared/components/challenge-listing/Listing/Bucket/index.jsx b/src/shared/components/challenge-listing/Listing/Bucket/index.jsx index 12370d911c..d0fb4f87da 100644 --- a/src/shared/components/challenge-listing/Listing/Bucket/index.jsx +++ b/src/shared/components/challenge-listing/Listing/Bucket/index.jsx @@ -42,7 +42,7 @@ export default function Bucket({ setFilterState, setSort, sort, - userHandle, + userId, expandedTags, expandTag, activeBucket, @@ -109,7 +109,7 @@ export default function Bucket({ prizeMode={prizeMode} key={item.id} selectChallengeDetailsTab={selectChallengeDetailsTab} - userHandle={userHandle} + userId={userId} expandedTags={expandedTags} expandTag={expandTag} domRef={addToRefs} @@ -187,7 +187,7 @@ Bucket.defaultProps = { newChallengeDetails: false, openChallengesInNewTabs: false, sort: null, - userHandle: '', + userId: '', expandedTags: [], expandTag: null, activeBucket: '', @@ -214,7 +214,7 @@ Bucket.propTypes = { setFilterState: PT.func.isRequired, setSort: PT.func.isRequired, sort: PT.string, - userHandle: PT.string, + userId: PT.string, expandedTags: PT.arrayOf(PT.number), expandTag: PT.func, activeBucket: PT.string, diff --git a/src/shared/components/challenge-listing/Listing/index.jsx b/src/shared/components/challenge-listing/Listing/index.jsx index eb5fb6ee0f..2fdbd0f9bd 100644 --- a/src/shared/components/challenge-listing/Listing/index.jsx +++ b/src/shared/components/challenge-listing/Listing/index.jsx @@ -117,7 +117,7 @@ function Listing({ setFilterState={setFilterState} setSort={sort => setSort(bucket, sort)} sort={sorts[bucket]} - userHandle={_.get(auth, 'user.handle')} + userId={_.get(auth, 'user.userId')} activeBucket={activeBucket} searchTimestamp={searchTimestamp} /> @@ -183,7 +183,7 @@ Listing.propTypes = { auth: PT.shape({ tokenV3: PT.string, user: PT.shape({ - handle: PT.string, + userId: PT.string, }), }).isRequired, challenges: PT.arrayOf(PT.shape()), From 9257c9d4ba687a3fb2da1adff785416675ba6db3 Mon Sep 17 00:00:00 2001 From: sr_jr Date: Sun, 7 Jun 2020 13:10:38 +0530 Subject: [PATCH 2/2] fix for issue #4384 --- .../components/challenge-listing/ChallengeCard/Status/index.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/components/challenge-listing/ChallengeCard/Status/index.jsx b/src/shared/components/challenge-listing/ChallengeCard/Status/index.jsx index 39160ca49b..17b1e26f58 100644 --- a/src/shared/components/challenge-listing/ChallengeCard/Status/index.jsx +++ b/src/shared/components/challenge-listing/ChallengeCard/Status/index.jsx @@ -223,7 +223,7 @@ export default function ChallengeStatus(props) { if (statusPhase) phaseMessage = statusPhase.name; else if (status === 'Draft') phaseMessage = DRAFT_MSG; - const showRegisterInfo = challenge.registrationOpen == 'Yes' && !challenge.users[userId]; + const showRegisterInfo = challenge.registrationOpen === 'Yes' && !challenge.users[userId]; return (