import PropTypes from 'prop-types' import React from 'react' import Modal from '../Modal' import { AVAILABLE_METRICS } from '../../../util/available-metrics' class NewPortfolioModalComponent extends React.Component { static propTypes = { show: PropTypes.bool.isRequired, callback: PropTypes.func.isRequired, } constructor(props) { super(props) this.metricCheckboxes = {} } componentDidMount() { this.reset() } reset() { if (this.textInput) { this.textInput.value = '' AVAILABLE_METRICS.forEach((metric) => { this.metricCheckboxes[metric].checked = true }) this.repeatsInput.value = 1 } } onSubmit() { this.props.callback(this.textInput.value, { enabledMetrics: AVAILABLE_METRICS.filter((metric) => this.metricCheckboxes[metric].checked), repeatsPerScenario: parseInt(this.repeatsInput.value), }) this.reset() } onCancel() { this.props.callback(undefined) this.reset() } render() { return (
{ e.preventDefault() this.onSubmit() }} >
(this.textInput = textInput)} />

Targets

Metrics
{AVAILABLE_METRICS.map((metric) => (
))}
(this.repeatsInput = repeatsInput)} />
) } } export default NewPortfolioModalComponent