diff --git a/client/src/components/settings/Certification.js b/client/src/components/settings/Certification.js index 6640b56885..ac47f8ab28 100644 --- a/client/src/components/settings/Certification.js +++ b/client/src/components/settings/Certification.js @@ -232,6 +232,7 @@ class CertificationSettings extends Component { ); renderProjectsFor = (certName, isCert) => { + console.log(isCert); const { username, isHonest, createFlashMessage, verifyCert } = this.props; const { superBlock } = first(projectMap[certName]); const certLocation = `/certification/${username}/${superBlock}`; @@ -278,55 +279,36 @@ class CertificationSettings extends Component { // legacy projects rendering - handleSubmit() { - console.log('handle'); + handleSubmit(values) { + console.log(values); } renderLegacyCertifications = certName => { + const { username, isHonest, createFlashMessage, verifyCert } = this.props; + const { superBlock } = first(legacyProjectMap[certName]); + const certLocation = `/certification/${username}/${superBlock}`; const challengeTitles = legacyProjectMap[certName].map(item => item.title); const { completedChallenges } = this.props; - + const isCertClaimed = this.getUserIsCertMap()[certName]; const initialObject = {}; - let fullform = 0; + let filledforms = 0; legacyProjectMap[certName].forEach(element => { let completedProject = find(completedChallenges, function(challenge) { return challenge['id'] === element['id']; }); - if (!completedProject) { initialObject[element.title] = ''; } else { initialObject[element.title] = completedProject.solution; - fullform++; + filledforms++; } }); - console.log(fullform); + const fullForm = filledforms === challengeTitles.length; - return ( - - -

{certName}

-
- - ); - }; - - renderLegacyProjectsFor = (certName, isCert) => { - const { username, isHonest, createFlashMessage, verifyCert } = this.props; - const { superBlock } = first(legacyProjectMap[certName]); - const certLocation = `/certification/${username}/${superBlock}`; const createClickHandler = superBlock => e => { e.preventDefault(); - if (isCert) { + if (isCertClaimed) { return navigate(certLocation); } return isHonest @@ -339,123 +321,45 @@ class CertificationSettings extends Component { }); }; - return legacyProjectMap[certName] - .map(({ title, id }) => ( - - -

{title}

- - - {this.getLegacyProjectSolution(id, title)} - - - )) - .concat([ - - + const buttonStyle = { + marginBottom: '1.45rem' + }; + + return ( + + +

{certName}

+ + {isCertClaimed ? ( +
- - - ]); - }; - - getLegacyProjectSolution = (projectId, projectTitle) => { - const { completedChallenges } = this.props; - const completedProject = find( - completedChallenges, - ({ id }) => projectId === id - ); - if (!completedProject) { - return null; - } - const { solution, githubLink, files } = completedProject; - const onClickHandler = () => - this.setState({ - solutionViewer: { - projectTitle, - files, - solution, - isOpen: true - } - }); - if (files && files.length) { - return ( - - ); - } - if (githubLink) { - return ( -
- - - Front End - - - Back End - - -
- ); - } - if (maybeUrlRE.test(solution)) { - return ( - - ); - } - return ( - +
+ ) : null} +
); }; render() { - // console.log(this.props.completedChallenges); - // console.log(getUserIsCertMap); const { solutionViewer: { files, solution, isOpen, projectTitle } } = this.state;