From 818442cfd1d42c68137fcc388541e823834d6484 Mon Sep 17 00:00:00 2001 From: lunarkid <4476442+dedywahyudi@users.noreply.github.com> Date: Tue, 20 Sep 2022 12:27:38 +0700 Subject: [PATCH 1/3] fix: challenge status missing --- .../challenge-detail/Header/index.jsx | 72 ++++++++++++++++++- .../challenge-detail/Header/style.scss | 48 +++++++++++-- 2 files changed, 113 insertions(+), 7 deletions(-) diff --git a/src/shared/components/challenge-detail/Header/index.jsx b/src/shared/components/challenge-detail/Header/index.jsx index 9898b37059..de9b90b2fb 100644 --- a/src/shared/components/challenge-detail/Header/index.jsx +++ b/src/shared/components/challenge-detail/Header/index.jsx @@ -30,6 +30,10 @@ import TabSelector from './TabSelector'; import style from './style.scss'; +/* Holds day and hour range in ms. */ +const HOUR_MS = 60 * 60 * 1000; +const DAY_MS = 24 * HOUR_MS; + export default function ChallengeHeader(props) { const { isLoggedIn, @@ -128,6 +132,26 @@ export default function ChallengeHeader(props) { */ const hasSubmissions = !_.isEmpty(mySubmissions); + const openPhases = sortedAllPhases.filter(p => p.isOpen); + let nextPhase = openPhases[0]; + if (hasRegistered && openPhases[0] && openPhases[0].name === 'Registration') { + nextPhase = openPhases[1] || {}; + } + const nextDeadline = nextPhase && nextPhase.name; + + const deadlineEnd = moment(nextPhase && phaseEndDate(nextPhase)); + const currentTime = moment(); + + let timeLeft = deadlineEnd.isAfter(currentTime) + ? deadlineEnd.diff(currentTime) : 0; + + let format; + if (timeLeft > DAY_MS) format = 'D[d] H[h]'; + else if (timeLeft > HOUR_MS) format = 'H[h] m[min]'; + else format = 'm[min] s[s]'; + + timeLeft = moment.duration(timeLeft).format(format); + let relevantPhases = []; if (showDeadlineDetail) { @@ -202,6 +226,41 @@ export default function ChallengeHeader(props) { const checkpointCount = checkpoints && checkpoints.numberOfPassedScreeningSubmissions; + let nextDeadlineMsg; + switch ((status || '').toLowerCase()) { + case 'active': + nextDeadlineMsg = ( +
+ Next Deadline: + {' '} + { + + {nextDeadline || '-'} + + } +
+ ); + break; + case 'completed': + nextDeadlineMsg = ( +
+ The challenge is finished. +
+ ); + break; + default: + nextDeadlineMsg = ( +
+ Status: + ‌ + + {_.upperFirst(_.lowerCase(status))} + +
+ ); + break; + } + // Legacy MMs have a roundId field, but new MMs do not. // This is used to disable registration/submission for legacy MMs. const isLegacyMM = isMM(challenge) && Boolean(challenge.roundId); @@ -382,7 +441,18 @@ export default function ChallengeHeader(props) {
- Competition Timeline + {nextDeadlineMsg} + { + (status || '').toLowerCase() === 'active' + && ( +
+ Current Deadline Ends:{' '} + + {timeLeft} + +
+ ) + }
Date: Wed, 5 Oct 2022 06:30:59 +0700 Subject: [PATCH 2/3] fix: status message in challenge details page --- .../challenge-detail/Header/index.jsx | 50 +++++++++---------- .../challenge-detail/Header/style.scss | 1 - 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/src/shared/components/challenge-detail/Header/index.jsx b/src/shared/components/challenge-detail/Header/index.jsx index de9b90b2fb..43c82b8b0a 100644 --- a/src/shared/components/challenge-detail/Header/index.jsx +++ b/src/shared/components/challenge-detail/Header/index.jsx @@ -17,6 +17,9 @@ import { PrimaryButton } from 'topcoder-react-ui-kit'; import { Link } from 'topcoder-react-utils'; import { COMPETITION_TRACKS } from 'utils/tc'; import { phaseEndDate } from 'utils/challenge-listing/helper'; +import { + getTimeLeft, +} from 'utils/challenge-detail/helper'; import LeftArrow from 'assets/images/arrow-prev.svg'; @@ -112,6 +115,10 @@ export default function ChallengeHeader(props) { registrationEnded = !regPhase.isOpen; } + const currentPhases = challenge.phases + .filter(p => p.name !== 'Registration' && p.isOpen) + .sort((a, b) => moment(a.scheduledEndDate).diff(b.scheduledEndDate))[0]; + const trackLower = track ? track.replace(' ', '-').toLowerCase() : 'design'; const eventNames = (events || []).map((event => (event.eventName || '').toUpperCase())); @@ -137,11 +144,16 @@ export default function ChallengeHeader(props) { if (hasRegistered && openPhases[0] && openPhases[0].name === 'Registration') { nextPhase = openPhases[1] || {}; } - const nextDeadline = nextPhase && nextPhase.name; const deadlineEnd = moment(nextPhase && phaseEndDate(nextPhase)); const currentTime = moment(); + const timeDiff = getTimeLeft(currentPhases, 'to go'); + + if (!timeDiff.late) { + timeDiff.text = timeDiff.text.replace('to go', ''); + } + let timeLeft = deadlineEnd.isAfter(currentTime) ? deadlineEnd.diff(currentTime) : 0; @@ -228,19 +240,6 @@ export default function ChallengeHeader(props) { let nextDeadlineMsg; switch ((status || '').toLowerCase()) { - case 'active': - nextDeadlineMsg = ( -
- Next Deadline: - {' '} - { - - {nextDeadline || '-'} - - } -
- ); - break; case 'completed': nextDeadlineMsg = (
@@ -249,15 +248,15 @@ export default function ChallengeHeader(props) { ); break; default: - nextDeadlineMsg = ( -
- Status: - ‌ - - {_.upperFirst(_.lowerCase(status))} - -
- ); + // nextDeadlineMsg = ( + //
+ // Status: + // ‌ + // + // {_.upperFirst(_.lowerCase(status))} + // + //
+ // ); break; } @@ -446,9 +445,9 @@ export default function ChallengeHeader(props) { (status || '').toLowerCase() === 'active' && (
- Current Deadline Ends:{' '} + {currentPhases && `${currentPhases.name} Ends: `} - {timeLeft} + {timeDiff.text}
) @@ -532,7 +531,6 @@ ChallengeHeader.propTypes = { timelineTemplateId: PT.string, reliabilityBonus: PT.any, userDetails: PT.any, - currentPhases: PT.any, numOfRegistrants: PT.any, numOfCheckpointSubmissions: PT.any, numOfSubmissions: PT.any, diff --git a/src/shared/components/challenge-detail/Header/style.scss b/src/shared/components/challenge-detail/Header/style.scss index cd1e155ae5..a8bfa1cec7 100644 --- a/src/shared/components/challenge-detail/Header/style.scss +++ b/src/shared/components/challenge-detail/Header/style.scss @@ -602,7 +602,6 @@ .current-phase { overflow-wrap: normal; - padding-left: 10px; @include xs-to-md { padding-left: 0; From ed237ca03d82a26ea8ae126c1d939625d151d65a Mon Sep 17 00:00:00 2001 From: lunarkid <4476442+dedywahyudi@users.noreply.github.com> Date: Thu, 6 Oct 2022 10:06:50 +0700 Subject: [PATCH 3/3] fix: timeline appeal response --- .../Header/DeadlinesPanel/index.jsx | 1 - .../challenge-detail/Header/index.jsx | 32 +++++++++++-------- .../challenge-detail/Header/style.scss | 3 +- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/shared/components/challenge-detail/Header/DeadlinesPanel/index.jsx b/src/shared/components/challenge-detail/Header/DeadlinesPanel/index.jsx index 7eb853efd1..081d958d84 100644 --- a/src/shared/components/challenge-detail/Header/DeadlinesPanel/index.jsx +++ b/src/shared/components/challenge-detail/Header/DeadlinesPanel/index.jsx @@ -35,7 +35,6 @@ export default function DeadlinesPanel({ deadlines }) { } } if (index === deadlines.length - 1) { - name = 'Winners Announced'; showRange = false; } diff --git a/src/shared/components/challenge-detail/Header/index.jsx b/src/shared/components/challenge-detail/Header/index.jsx index 43c82b8b0a..12b0281f6b 100644 --- a/src/shared/components/challenge-detail/Header/index.jsx +++ b/src/shared/components/challenge-detail/Header/index.jsx @@ -213,26 +213,23 @@ export default function ChallengeHeader(props) { || phaseEndDate(p).getTime() < endPhaseDate)); relevantPhases.push({ id: -1, - name: 'Winners', + name: 'Winners Announced', isOpen: false, actualEndDate: endPhaseDate, scheduledEndDate: endPhaseDate, }); } else if (relevantPhases.length > 1) { - const lastPhase = relevantPhases[relevantPhases.length - 1]; - const lastPhaseTime = phaseEndDate(lastPhase).getTime(); - + // const lastPhase = relevantPhases[relevantPhases.length - 1]; + // const lastPhaseTime = phaseEndDate(lastPhase).getTime(); const appealsEndDate = phaseEndDate(sortedAllPhases[sortedAllPhases.length - 1]); - const appealsEnd = appealsEndDate.getTime(); - if (lastPhaseTime < appealsEnd) { - relevantPhases.push({ - id: -1, - name: 'Winners', - isOpen: false, - actualEndDate: appealsEndDate, - scheduledEndDate: appealsEndDate, - }); - } + // const appealsEnd = appealsEndDate.getTime(); + relevantPhases.push({ + id: -1, + name: 'Winners Announced', + isOpen: false, + actualEndDate: appealsEndDate, + scheduledEndDate: appealsEndDate, + }); } } @@ -247,6 +244,13 @@ export default function ChallengeHeader(props) {
); break; + case 'draft': + nextDeadlineMsg = ( +
+ In Draft +
+ ); + break; default: // nextDeadlineMsg = ( //
diff --git a/src/shared/components/challenge-detail/Header/style.scss b/src/shared/components/challenge-detail/Header/style.scss index a8bfa1cec7..f97c457a6d 100644 --- a/src/shared/components/challenge-detail/Header/style.scss +++ b/src/shared/components/challenge-detail/Header/style.scss @@ -596,7 +596,8 @@ } } - .completed { + .completed, + .draft { border-right: none; }