From 263b20fad9fc1dce3aaa76f2062d0e5ea4cc3fe2 Mon Sep 17 00:00:00 2001 From: Justin Gasper Date: Wed, 18 Jan 2023 15:29:59 +1100 Subject: [PATCH] FIX SUBMISSION PHASE DISPLAY ON 2 ROUND CHALLENGE --- src/components/ChallengeEditor/index.js | 2 ++ src/reducers/challenges.js | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/components/ChallengeEditor/index.js b/src/components/ChallengeEditor/index.js index 1ec2f781..d2acf434 100644 --- a/src/components/ChallengeEditor/index.js +++ b/src/components/ChallengeEditor/index.js @@ -842,6 +842,8 @@ class ChallengeEditor extends Component { moment(newChallenge.phases[index]['scheduledEndDate']).isAfter() if (newChallenge.phases[index].name === 'Submission') { newChallenge.phases[index].isStartTimeActive = true + } else if (newChallenge.phases[index].name === 'Checkpoint Submission') { + newChallenge.phases[index].isStartTimeActive = true } else { newChallenge.phases[index].isStartTimeActive = index <= 0 } diff --git a/src/reducers/challenges.js b/src/reducers/challenges.js index cbd4e538..71f7238b 100644 --- a/src/reducers/challenges.js +++ b/src/reducers/challenges.js @@ -104,6 +104,21 @@ export default function (state = initialState, action) { case CREATE_CHALLENGE_FAILURE: return { ...state, isLoading: false, attachments: [], challenge: null, failedToLoad: true, errorMessage: _.get(action, 'error.response.data.message', '') } case LOAD_CHALLENGE_DETAILS_SUCCESS: { + const phases = action.payload.phases + const swapPhaseAtIndex = (phaseA, phaseB) => { + const phaseAIndex = _.findIndex(phases, { name: phaseA }) + let phaseBIndex = _.findIndex(phases, { name: phaseB }) + if (phaseAIndex >= 0 && phaseBIndex >= 0) { + const tmp = phases[phaseAIndex] + phases.splice(phaseAIndex, 1) + phaseBIndex = _.findIndex(phases, { name: phaseB }) + phases.splice(phaseBIndex, 0, tmp) + } + } + swapPhaseAtIndex('Checkpoint Submission', 'Submission') + swapPhaseAtIndex('Checkpoint Screening', 'Submission') + swapPhaseAtIndex('Checkpoint Review', 'Submission') + return { ...state, challengeDetails: { ...action.payload,