fix(client): handle verification of full-stack cert once (#46588)

pull/46614/head^2
Shaun Hamilton 2022-06-20 21:14:22 +01:00 committed by GitHub
parent e3ed3d7695
commit 7a91407184
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 13 deletions

View File

@ -26,6 +26,10 @@ import {
} from '../../utils/ajax';
import { certMap } from '../../resources/cert-and-project-map';
import { completedChallengesSelector } from '..';
import {
certTypes,
certTypeIdMap
} from '../../../../config/certification-settings';
import {
updateUserFlagComplete,
updateUserFlagError,
@ -169,17 +173,20 @@ function* validateUsernameSaga({ payload }) {
function* verifyCertificationSaga({ payload }) {
// check redux if can claim cert before calling backend
const completedChallenges = yield select(completedChallengesSelector);
const currentCert = certMap.find(cert => cert.certSlug === payload);
const currentCertIds = currentCert?.projects.map(project => project.id);
const completedChallenges = yield select(completedChallengesSelector);
const certTitle = currentCert?.title || payload;
// (20/06/2022) Full Stack client-side validation is already done here:
// https://github.com/freeCodeCamp/freeCodeCamp/blob/main/client/src/components/settings/certification.js#L309
if (currentCert?.id !== certTypeIdMap[certTypes.fullStack]) {
const flash = {
type: 'info',
message: 'flash.incomplete-steps',
variables: { name: certTitle }
};
const currentCertIds = currentCert?.projects?.map(project => project.id);
const canClaimCert = currentCertIds.every(id =>
completedChallenges.find(challenge => challenge.id === id)
);
@ -188,6 +195,7 @@ function* verifyCertificationSaga({ payload }) {
yield put(createFlashMessage(flash));
return;
}
}
// redux says challenges are complete, call back end
try {