Skip to content
Snippets Groups Projects
Commit 0929687b authored by Alf Eaton's avatar Alf Eaton
Browse files

Use form.registeredFields

parent 6c38ba61
No related branches found
No related tags found
No related merge requests found
import React from 'react' import React from 'react'
import { Field, FormSection } from 'redux-form' import { Field } from 'redux-form'
import { map } from 'lodash'
import Validot from './Validot' import Validot from './Validot'
import { connect } from 'react-redux'
// TODO: build sections and fields from configuration // TODO: build sections and fields from configuration
// TODO: is the order of map(form.registeredFields) guaranteed to be the same?
// TODO: use journal config instead of form.registeredFields once using it to build the form
const Validots = ({ journal, valid, handleSubmit }) => ( const Validots = ({ form, journal, valid, handleSubmit }) => (
<div> <div>
<FormSection name="metadata"> {form.registeredFields && (
<Field name="title" component={Validot}/> map(form.registeredFields, field => (
<Field name="abstract" component={Validot}/> <div>
<Field name="authors" component={Validot}/> <Field name={field.name} component={Validot}/>
<Field name="keywords" component={Validot}/> </div>
</FormSection> ))
)}
<FormSection name="declarations">
{journal.declarations.questions.map(question => (
<Field name={question.id} component={Validot}/>
))}
</FormSection>
<FormSection name="suggestions">
<FormSection name="reviewers">
<Field name="suggested" component={Validot}/>
<Field name="opposed" component={Validot}/>
</FormSection>
<FormSection name="editors">
<Field name="suggested" component={Validot}/>
<Field name="opposed" component={Validot}/>
</FormSection>
</FormSection>
<FormSection name="notes">
<Field name="fundingAcknowledgement" component={Validot}/>
<Field name="specialInstructions" component={Validot}/>
</FormSection>
<FormSection name="files">
<Field name="supplementary" component={Validot}/>
</FormSection>
<button <button
onClick={handleSubmit} onClick={handleSubmit}
...@@ -45,4 +24,8 @@ const Validots = ({ journal, valid, handleSubmit }) => ( ...@@ -45,4 +24,8 @@ const Validots = ({ journal, valid, handleSubmit }) => (
</div> </div>
) )
export default Validots export default connect(
state => ({
form: state.form.submit
})
)(Validots)
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment