Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
loadChallengeDetails: (tokens, challengeId) => {
const a = actions.challenge;
dispatch(a.getDetailsInit(challengeId));
dispatch(a.getDetailsDone(challengeId, tokens.tokenV3, tokens.tokenV2))
.then((res) => {
const ch = res.payload;
if (ch.track === 'DESIGN') {
const p = ch.allPhases
.filter(x => x.phaseType === 'Checkpoint Review');
if (p.length && p[0].phaseStatus === 'Closed') {
dispatch(a.fetchCheckpointsInit());
dispatch(a.fetchCheckpointsDone(tokens.tokenV2, challengeId));
} else dispatch(a.dropCheckpoints());
} else dispatch(a.dropCheckpoints());
if (ch.status === 'COMPLETED') {
dispatch(a.loadResultsInit(challengeId));
dispatch(a.loadResultsDone(tokens, challengeId, ch.track.toLowerCase()));
} else dispatch(a.dropResults());
loadMySubmissions: (tokens, challengeId) => {
const a = actions.challenge;
dispatch(a.getSubmissionsInit(challengeId));
dispatch(a.getSubmissionsDone(challengeId, tokens.tokenV2));
},
});
registerForChallenge: (auth, challengeId) => {
const a = actions.challenge;
dispatch(a.registerInit());
dispatch(a.registerDone(auth, challengeId));
},
reloadChallengeDetails: (tokens, challengeId) => {
const loadHeaderData = ({ handle, tokenV3 }) => {
dispatch(profileActions.loadProfile(handle));
dispatch(profileActions.getAchievementsInit());
dispatch(actions.challenge.getActiveChallengesCountInit());
dispatch(profileActions.getAchievementsDone(handle));
dispatch(actions.challenge.getActiveChallengesCountDone(handle, tokenV3));
};
unregisterFromChallenge: (auth, challengeId) => {
const a = actions.challenge;
dispatch(a.unregisterInit());
dispatch(a.unregisterDone(auth, challengeId));
},
};
const loadHeaderData = ({ handle, tokenV3 }) => {
dispatch(profileActions.loadProfile(handle));
dispatch(profileActions.getAchievementsInit());
dispatch(actions.challenge.getActiveChallengesCountInit());
dispatch(profileActions.getAchievementsDone(handle));
dispatch(actions.challenge.getActiveChallengesCountDone(handle, tokenV3));
};
loadChallengeDetails: (tokens, challengeId) => {
const a = actions.challenge;
dispatch(a.getDetailsInit(challengeId));
dispatch(a.getDetailsDone(challengeId, tokens.tokenV3, tokens.tokenV2));
},
CHALLENGE_FORUM: 'challenge_forum',
};
/**
* Toggles checkpoint feedback. If second argument is provided, it
* will just open / close the checkpoint depending on its value being
* true or false.
* @param {Number} id
* @param {Boolean} open
* @return {Object}
*/
function toggleCheckpointFeedback(id, open) {
return { id, open };
}
export default _.merge({ challenge: actions.challenge }, createActions({
CHALLENGE: {
SELECT_TAB: _.identity,
TOGGLE_CHECKPOINT_FEEDBACK: toggleCheckpointFeedback,
},
}));