diff --git a/components/ApiUserForm.js b/components/ApiUserForm.js index 52a3bb5..9ff1b8b 100644 --- a/components/ApiUserForm.js +++ b/components/ApiUserForm.js @@ -17,6 +17,40 @@ const validationSchema = yup.object({ name: yup.string().required('Please enter your name.') }) +// Field layout (assumes all text fields) +const fieldLayout = [ + { + title: 'Developer information', + fields: [ + { + title: 'Developer name', + field: 'name' + }, + { + title: 'Company', + field: 'company' + } + ] + }, + { + title: 'Application information', + fields: [ + { + title: 'Application name', + field: 'appName' + }, + { + title: 'Application purpose', + field: 'appPurpose' + }, + { + title: 'Application URL', + field: 'appUrl' + } + ] + } +] + /** * Creates a blank ApiUser object to be filled out. */ @@ -85,98 +119,39 @@ class ApiUserForm extends Component {
- - - Developer information - - - Developer name - - - {errors.name} - - - - - Company - - - {errors.company} - - - - - - - - Application information - - - Application name - - - {errors.appName} - - - - - Application purpose - - - {errors.appPurpose} - - - - - Application URL - - - {errors.appUrl} - - - - - + { + fieldLayout.map((col, colIndex) => ( + + + {col.title} + + { + col.fields.map((field, fieldIndex) => { + const fieldName = field.field + return ( + + {field.title} + + + {errors[fieldName]} + + + ) + }) + } + + + + )) + } @@ -202,16 +177,12 @@ class ApiUserForm extends Component { {createUser && - }
)} - )