From 17a2bae5b92362fb0ef841f6fa220b9f69970d6f Mon Sep 17 00:00:00 2001 From: Ahmad Abdolsaheb Date: Wed, 20 Mar 2019 16:46:50 +0300 Subject: [PATCH] fix: add initialValues to the form --- .../src/components/settings/Certification.js | 73 ++++++++++++------- 1 file changed, 47 insertions(+), 26 deletions(-) diff --git a/client/src/components/settings/Certification.js b/client/src/components/settings/Certification.js index 9461ed6fba..6640b56885 100644 --- a/client/src/components/settings/Certification.js +++ b/client/src/components/settings/Certification.js @@ -16,7 +16,8 @@ import { projectMap, legacyProjectMap } from '../../resources/certProjectMap'; import SectionHeader from './SectionHeader'; import SolutionViewer from './SolutionViewer'; import { FullWidthRow, Spacer } from '../helpers'; -// import { Form } from '../formHelpers'; +import { Form } from '../formHelpers'; + import { maybeUrlRE } from '../../utils'; import './certification.css'; @@ -113,6 +114,7 @@ class CertificationSettings extends Component { super(props); this.state = { ...initialState }; + this.handleSubmit = this.handleSubmit.bind(this); } createHandleLinkButtonClick = to => e => { @@ -230,9 +232,6 @@ class CertificationSettings extends Component { ); renderProjectsFor = (certName, isCert) => { - console.log(certName); - console.log(this.getUserIsCertMap()); - console.log(this.getUserIsCertMap()[certName]); const { username, isHonest, createFlashMessage, verifyCert } = this.props; const { superBlock } = first(projectMap[certName]); const certLocation = `/certification/${username}/${superBlock}`; @@ -277,30 +276,51 @@ class CertificationSettings extends Component { ]); }; - renderLegacyCertifications = certName => ( - - -

{certName}

- - - - - - - - - {this.renderLegacyProjectsFor( - certName, - this.getUserIsCertMap()[certName] - )} - -
Project NameSolution
-
- ); + // legacy projects rendering + + handleSubmit() { + console.log('handle'); + } + + renderLegacyCertifications = certName => { + const challengeTitles = legacyProjectMap[certName].map(item => item.title); + const { completedChallenges } = this.props; + + const initialObject = {}; + let fullform = 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++; + } + }); + + console.log(fullform); + + return ( + + +

{certName}

+
+ + ); + }; renderLegacyProjectsFor = (certName, isCert) => { - console.log(certName); - console.log(this.getUserIsCertMap()[certName]); const { username, isHonest, createFlashMessage, verifyCert } = this.props; const { superBlock } = first(legacyProjectMap[certName]); const certLocation = `/certification/${username}/${superBlock}`; @@ -318,6 +338,7 @@ class CertificationSettings extends Component { 'honesty policy' }); }; + return legacyProjectMap[certName] .map(({ title, id }) => (