fix: add initialValues to the form
This commit is contained in:
committed by
Mrugesh Mohapatra
parent
abf8f2777c
commit
17a2bae5b9
@ -16,7 +16,8 @@ import { projectMap, legacyProjectMap } from '../../resources/certProjectMap';
|
|||||||
import SectionHeader from './SectionHeader';
|
import SectionHeader from './SectionHeader';
|
||||||
import SolutionViewer from './SolutionViewer';
|
import SolutionViewer from './SolutionViewer';
|
||||||
import { FullWidthRow, Spacer } from '../helpers';
|
import { FullWidthRow, Spacer } from '../helpers';
|
||||||
// import { Form } from '../formHelpers';
|
import { Form } from '../formHelpers';
|
||||||
|
|
||||||
import { maybeUrlRE } from '../../utils';
|
import { maybeUrlRE } from '../../utils';
|
||||||
|
|
||||||
import './certification.css';
|
import './certification.css';
|
||||||
@ -113,6 +114,7 @@ class CertificationSettings extends Component {
|
|||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this.state = { ...initialState };
|
this.state = { ...initialState };
|
||||||
|
this.handleSubmit = this.handleSubmit.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
createHandleLinkButtonClick = to => e => {
|
createHandleLinkButtonClick = to => e => {
|
||||||
@ -230,9 +232,6 @@ class CertificationSettings extends Component {
|
|||||||
);
|
);
|
||||||
|
|
||||||
renderProjectsFor = (certName, isCert) => {
|
renderProjectsFor = (certName, isCert) => {
|
||||||
console.log(certName);
|
|
||||||
console.log(this.getUserIsCertMap());
|
|
||||||
console.log(this.getUserIsCertMap()[certName]);
|
|
||||||
const { username, isHonest, createFlashMessage, verifyCert } = this.props;
|
const { username, isHonest, createFlashMessage, verifyCert } = this.props;
|
||||||
const { superBlock } = first(projectMap[certName]);
|
const { superBlock } = first(projectMap[certName]);
|
||||||
const certLocation = `/certification/${username}/${superBlock}`;
|
const certLocation = `/certification/${username}/${superBlock}`;
|
||||||
@ -277,30 +276,51 @@ class CertificationSettings extends Component {
|
|||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
renderLegacyCertifications = certName => (
|
// legacy projects rendering
|
||||||
<FullWidthRow key={certName}>
|
|
||||||
<Spacer />
|
handleSubmit() {
|
||||||
<h3>{certName}</h3>
|
console.log('handle');
|
||||||
<Table>
|
}
|
||||||
<thead>
|
|
||||||
<tr>
|
renderLegacyCertifications = certName => {
|
||||||
<th>Project Name</th>
|
const challengeTitles = legacyProjectMap[certName].map(item => item.title);
|
||||||
<th>Solution</th>
|
const { completedChallenges } = this.props;
|
||||||
</tr>
|
|
||||||
</thead>
|
const initialObject = {};
|
||||||
<tbody>
|
let fullform = 0;
|
||||||
{this.renderLegacyProjectsFor(
|
legacyProjectMap[certName].forEach(element => {
|
||||||
certName,
|
let completedProject = find(completedChallenges, function(challenge) {
|
||||||
this.getUserIsCertMap()[certName]
|
return challenge['id'] === element['id'];
|
||||||
)}
|
});
|
||||||
</tbody>
|
|
||||||
</Table>
|
if (!completedProject) {
|
||||||
</FullWidthRow>
|
initialObject[element.title] = '';
|
||||||
);
|
} else {
|
||||||
|
initialObject[element.title] = completedProject.solution;
|
||||||
|
fullform++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(fullform);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<FullWidthRow key={certName}>
|
||||||
|
<Spacer />
|
||||||
|
<h3>{certName}</h3>
|
||||||
|
<Form
|
||||||
|
buttonText={'Claim Certification'}
|
||||||
|
formFields={challengeTitles}
|
||||||
|
id={certName}
|
||||||
|
initialValues={{
|
||||||
|
...initialObject
|
||||||
|
}}
|
||||||
|
submit={this.handleSubmit}
|
||||||
|
/>
|
||||||
|
</FullWidthRow>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
renderLegacyProjectsFor = (certName, isCert) => {
|
renderLegacyProjectsFor = (certName, isCert) => {
|
||||||
console.log(certName);
|
|
||||||
console.log(this.getUserIsCertMap()[certName]);
|
|
||||||
const { username, isHonest, createFlashMessage, verifyCert } = this.props;
|
const { username, isHonest, createFlashMessage, verifyCert } = this.props;
|
||||||
const { superBlock } = first(legacyProjectMap[certName]);
|
const { superBlock } = first(legacyProjectMap[certName]);
|
||||||
const certLocation = `/certification/${username}/${superBlock}`;
|
const certLocation = `/certification/${username}/${superBlock}`;
|
||||||
@ -318,6 +338,7 @@ class CertificationSettings extends Component {
|
|||||||
'honesty policy'
|
'honesty policy'
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return legacyProjectMap[certName]
|
return legacyProjectMap[certName]
|
||||||
.map(({ title, id }) => (
|
.map(({ title, id }) => (
|
||||||
<tr className='project-row' key={id}>
|
<tr className='project-row' key={id}>
|
||||||
|
Reference in New Issue
Block a user