fix(client): handle verification of full-stack cert once (#46588)
parent
e3ed3d7695
commit
7a91407184
|
@ -26,6 +26,10 @@ import {
|
||||||
} from '../../utils/ajax';
|
} from '../../utils/ajax';
|
||||||
import { certMap } from '../../resources/cert-and-project-map';
|
import { certMap } from '../../resources/cert-and-project-map';
|
||||||
import { completedChallengesSelector } from '..';
|
import { completedChallengesSelector } from '..';
|
||||||
|
import {
|
||||||
|
certTypes,
|
||||||
|
certTypeIdMap
|
||||||
|
} from '../../../../config/certification-settings';
|
||||||
import {
|
import {
|
||||||
updateUserFlagComplete,
|
updateUserFlagComplete,
|
||||||
updateUserFlagError,
|
updateUserFlagError,
|
||||||
|
@ -169,17 +173,20 @@ function* validateUsernameSaga({ payload }) {
|
||||||
|
|
||||||
function* verifyCertificationSaga({ payload }) {
|
function* verifyCertificationSaga({ payload }) {
|
||||||
// check redux if can claim cert before calling backend
|
// check redux if can claim cert before calling backend
|
||||||
const completedChallenges = yield select(completedChallengesSelector);
|
|
||||||
const currentCert = certMap.find(cert => cert.certSlug === payload);
|
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;
|
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 = {
|
const flash = {
|
||||||
type: 'info',
|
type: 'info',
|
||||||
message: 'flash.incomplete-steps',
|
message: 'flash.incomplete-steps',
|
||||||
variables: { name: certTitle }
|
variables: { name: certTitle }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const currentCertIds = currentCert?.projects?.map(project => project.id);
|
||||||
const canClaimCert = currentCertIds.every(id =>
|
const canClaimCert = currentCertIds.every(id =>
|
||||||
completedChallenges.find(challenge => challenge.id === id)
|
completedChallenges.find(challenge => challenge.id === id)
|
||||||
);
|
);
|
||||||
|
@ -188,6 +195,7 @@ function* verifyCertificationSaga({ payload }) {
|
||||||
yield put(createFlashMessage(flash));
|
yield put(createFlashMessage(flash));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// redux says challenges are complete, call back end
|
// redux says challenges are complete, call back end
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue