import classNames from 'classnames' import Controls from 'Components/Controls' import InputSuggestions from 'Components/conversation/InputSuggestions' import PeriodSwitch from 'Components/PeriodSwitch' import withColours from 'Components/utils/withColours' import withLanguage from 'Components/utils/withLanguage' import withSitePaths from 'Components/utils/withSitePaths' import { encodeRuleName } from 'Engine/rules' import { compose, isEmpty, isNil, propEq } from 'ramda' import React, { Component, PureComponent } from 'react' import { withTranslation } from 'react-i18next' import { connect } from 'react-redux' import { Link } from 'react-router-dom' import { change, Field, formValueSelector, reduxForm } from 'redux-form' import { analysisWithDefaultsSelector, flatRulesSelector, noUserInputSelector } from 'Selectors/analyseSelectors' import Animate from 'Ui/animate' import AnimatedTargetValue from 'Ui/AnimatedTargetValue' import CurrencyInput from './CurrencyInput/CurrencyInput' import QuickLinks from './QuickLinks' import './TargetSelection.css' export default compose( withTranslation(), withColours, reduxForm({ form: 'conversation', destroyOnUnmount: false }), connect( state => ({ getTargetValue: dottedName => formValueSelector('conversation')(state, dottedName), analysis: analysisWithDefaultsSelector(state), flatRules: flatRulesSelector(state), noUserInput: noUserInputSelector(state), conversationStarted: state.conversationStarted, activeInput: state.activeTargetInput, objectifs: state.simulation?.config.objectifs || [] }), dispatch => ({ setFormValue: (field, name) => dispatch(change('conversation', field, name)), setActiveInput: name => dispatch({ type: 'SET_ACTIVE_TARGET_INPUT', name }) }) ) )( class TargetSelection extends PureComponent { state = { initialRender: true } componentDidMount() { const props = this.props const targets = props.analysis ? props.analysis.targets : [] // Initialize defaultValue for target that can't be computed targets .filter( target => (!target.formule || isEmpty(target.formule)) && (!isNil(target.defaultValue) || !isNil(target.explanation?.defaultValue)) && !props.getTargetValue(target.dottedName) ) .forEach(target => { props.setFormValue( target.dottedName, !isNil(target.defaultValue) ? target.defaultValue : target.explanation?.defaultValue ) }) if (this.state.initialRender) { this.setState({ initialRender: false }) } } render() { let { colours, noUserInput, analysis } = this.props, inversionFail = analysis.cache.inversionFail return (
{target['résumé']}
} ) }) let CurrencyField = withColours(props => { return (