diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-11-11 00:51:23 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-11 00:51:23 +0100 |
| commit | e1716ee419c218f879c046917eaeb1e566230b0e (patch) | |
| tree | 399969e871ef89f427707c927ff5e65d4c14eba8 /frontend/src/components/modals/custom-components/NewPortfolioModalComponent.js | |
| parent | f3f8d1d494a08a032940c6587c7865cd0ac0dd7a (diff) | |
| parent | e6c36a309c7372bb0de3ae4a3277e91c1ee4913b (diff) | |
Merge pull request #62 from atlarge-research/bug/tutorial
Implement various fixes in preparation for tutorial
Diffstat (limited to 'frontend/src/components/modals/custom-components/NewPortfolioModalComponent.js')
| -rw-r--r-- | frontend/src/components/modals/custom-components/NewPortfolioModalComponent.js | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/frontend/src/components/modals/custom-components/NewPortfolioModalComponent.js b/frontend/src/components/modals/custom-components/NewPortfolioModalComponent.js index 67646e2c..3c6b8724 100644 --- a/frontend/src/components/modals/custom-components/NewPortfolioModalComponent.js +++ b/frontend/src/components/modals/custom-components/NewPortfolioModalComponent.js @@ -5,15 +5,23 @@ import Modal from '../Modal' import { AVAILABLE_METRICS, METRIC_NAMES } from '../../../util/available-metrics' const NewPortfolioModalComponent = ({ show, callback }) => { + const form = useRef(null) const textInput = useRef(null) const repeatsInput = useRef(null) const metricCheckboxes = useRef({}) - const onSubmit = () => - callback(textInput.current.value, { - enabledMetrics: AVAILABLE_METRICS.filter((metric) => metricCheckboxes.current[metric].checked), - repeatsPerScenario: parseInt(repeatsInput.current.value), - }) + const onSubmit = () => { + if (form.current.reportValidity()) { + callback(textInput.current.value, { + enabledMetrics: AVAILABLE_METRICS.filter((metric) => metricCheckboxes.current[metric].checked), + repeatsPerScenario: parseInt(repeatsInput.current.value), + }) + + return true + } else { + return false + } + } const onCancel = () => callback(undefined) return ( @@ -23,6 +31,7 @@ const NewPortfolioModalComponent = ({ show, callback }) => { e.preventDefault() this.onSubmit() }} + innerRef={form} > <FormGroup> <Label for="name">Name</Label> |
