|
| 1 | +import _ from 'lodash' |
| 2 | +// import NumberText from '../../components/NumberText/NumberText' |
| 3 | +import { findProduct } from '../projectWizard' |
| 4 | + |
| 5 | + |
| 6 | +const isFileRequired = (project, subSections) => { |
| 7 | + const subSection = _.find(subSections, (s) => s.type === 'questions') |
| 8 | + const fields = _.filter(subSection.questions, q => q.type.indexOf('see-attached') > -1) |
| 9 | + // iterate over all seeAttached type fields to check |
| 10 | + // if any see attached is checked. |
| 11 | + return _.some(_.map( |
| 12 | + _.map(fields, 'fieldName'), |
| 13 | + fn => _.get(project, `${fn}.seeAttached`) |
| 14 | + )) |
| 15 | +} |
| 16 | + |
| 17 | +const sections = [ |
| 18 | + { |
| 19 | + id: 'appDefinition', |
| 20 | + title: (project, showProduct) => { |
| 21 | + const product = _.get(project, 'details.products[0]') |
| 22 | + if (showProduct && product) { |
| 23 | + const prd = findProduct(product) |
| 24 | + if (prd) return prd.name |
| 25 | + } |
| 26 | + return 'Definition' |
| 27 | + }, |
| 28 | + required: true, |
| 29 | + description: 'Please answer a few basic questions about your project. You can also provide the needed information in a supporting document--add a link in the notes section or upload it below.', |
| 30 | + subSections: [ |
| 31 | + { |
| 32 | + id: 'projectName', |
| 33 | + required: true, |
| 34 | + validationError: 'Please provide a name to your project', |
| 35 | + fieldName: 'name', |
| 36 | + description: '', |
| 37 | + title: 'Project Name', |
| 38 | + type: 'project-name' |
| 39 | + }, |
| 40 | + { |
| 41 | + id: 'questions', |
| 42 | + required: true, |
| 43 | + hideTitle: true, |
| 44 | + title: 'Questions', |
| 45 | + description: '', |
| 46 | + type: 'questions', |
| 47 | + questions: [ |
| 48 | + { |
| 49 | + id: 'projectInfo', |
| 50 | + fieldName: 'description', |
| 51 | + // required is not needed if we specifiy validations |
| 52 | + // required: true, |
| 53 | + validations: 'isRequired,minLength:160', |
| 54 | + validationErrors: { |
| 55 | + isRequired: 'Please describe your application', |
| 56 | + minLength: 'Please enter at least 160 characters' |
| 57 | + }, |
| 58 | + description: 'Brief Description of your application', |
| 59 | + title: 'Description', |
| 60 | + type: 'textbox' |
| 61 | + } |
| 62 | + |
| 63 | + ] |
| 64 | + }, |
| 65 | + { |
| 66 | + id: 'notes', |
| 67 | + fieldName: 'details.appDefinition.notes', |
| 68 | + title: 'Additional Notes', |
| 69 | + description: 'Please detail any other additional information, you will be able to upload files on the next screen', |
| 70 | + type: 'notes' |
| 71 | + }, |
| 72 | + { |
| 73 | + id: 'files', |
| 74 | + required: isFileRequired, |
| 75 | + title: (project) => `Project Files (${_.get(project, 'attachments', []).length})` || 'Files', |
| 76 | + description: '', |
| 77 | + type: 'files', |
| 78 | + fieldName: 'attachments' |
| 79 | + } |
| 80 | + |
| 81 | + |
| 82 | + |
| 83 | + |
| 84 | + ] |
| 85 | + } |
| 86 | + |
| 87 | + |
| 88 | +] |
| 89 | + |
| 90 | +export default sections |
| 91 | + |
| 92 | +export const basicSections = [ |
| 93 | + { |
| 94 | + id: 'appDefinition', |
| 95 | + title: '', |
| 96 | + required: true, |
| 97 | + description: 'Please answer a few basic questions about your project and, as an option, add links to supporting documents in the “Notes” section. If you have any files to upload, you’ll be able to do so later.', |
| 98 | + subSections: [ |
| 99 | + { |
| 100 | + id: 'projectName', |
| 101 | + required: true, |
| 102 | + validationError: 'Please provide a name to your project', |
| 103 | + fieldName: 'name', |
| 104 | + description: '', |
| 105 | + title: 'Project Name', |
| 106 | + type: 'project-name' |
| 107 | + }, |
| 108 | + { |
| 109 | + id: 'questions', |
| 110 | + required: true, |
| 111 | + hideTitle: true, |
| 112 | + title: 'Questions', |
| 113 | + description: '', |
| 114 | + type: 'questions', |
| 115 | + questions: [ |
| 116 | + { |
| 117 | + id: 'projectInfo', |
| 118 | + fieldName: 'description', |
| 119 | + // required is not needed if we specifiy validations |
| 120 | + // required: true, |
| 121 | + validations: 'isRequired,minLength:160', |
| 122 | + validationErrors: { |
| 123 | + isRequired: 'Please provide a description of your application', |
| 124 | + minLength: 'Please enter at least 160 characters' |
| 125 | + }, |
| 126 | + description: 'Brief Description of your application', |
| 127 | + title: 'Description', |
| 128 | + type: 'textbox' |
| 129 | + } |
| 130 | + |
| 131 | + ] |
| 132 | + }, |
| 133 | + { |
| 134 | + id: 'notes', |
| 135 | + fieldName: 'details.appDefinition.notes', |
| 136 | + title: 'Additional Notes', |
| 137 | + description: 'Please detail any other additional information', |
| 138 | + type: 'notes' |
| 139 | + } |
| 140 | + ] |
| 141 | + } |
| 142 | + |
| 143 | + |
| 144 | +] |
0 commit comments