From 048be37a0790737bf93f7f5be1aad47c958d73da Mon Sep 17 00:00:00 2001 From: Johan Girod Date: Thu, 10 Jan 2019 17:49:35 +0100 Subject: [PATCH] Ajoute une inversion pour pouvoir partir du revenu disponible --- source/components/SalarySimulation.js | 4 +- source/components/SimpleSimulation.js | 20 +++---- source/components/TargetSelection.js | 52 +++++++------------ .../simulationConfigs/assimilé.yaml | 4 ++ source/components/ui/index.css | 3 +- source/règles/base.yaml | 2 + source/selectors/analyseSelectors.js | 1 + source/selectors/regleSelectors.js | 8 ++- source/sites/mycompanyinfrance.fr/App.js | 7 +-- .../pages/SocialSecurity/AssimiléSalarié.js | 2 +- .../sites/mycompanyinfrance.fr/sitePaths.js | 3 ++ source/storage/persistEverything.js | 8 ++- 12 files changed, 57 insertions(+), 57 deletions(-) diff --git a/source/components/SalarySimulation.js b/source/components/SalarySimulation.js index 2bb36124b..fd0f53aa7 100644 --- a/source/components/SalarySimulation.js +++ b/source/components/SalarySimulation.js @@ -185,7 +185,7 @@ export default compose( /> )} - {!location.pathname.endsWith('/simulation') && validInputEntered && ( + {/* {!location.pathname.endsWith('/simulation') && validInputEntered && (
{arePreviousAnswers && conversationStarted && ( @@ -229,7 +229,7 @@ export default compose( - )} + )} */} ) } diff --git a/source/components/SimpleSimulation.js b/source/components/SimpleSimulation.js index b33f905d6..011647957 100644 --- a/source/components/SimpleSimulation.js +++ b/source/components/SimpleSimulation.js @@ -23,20 +23,14 @@ export default compose( displayAnswers: false } render() { - let { children, noNextSteps, previousAnswers, noUserInput } = this.props + let { children, noNextSteps, previousAnswers } = this.props return ( <> - {!isEmpty(previousAnswers) && ( - - )} - {this.state.displayAnswers && ( this.setState({ displayAnswers: false })} /> )} + + {children} @@ -46,7 +40,13 @@ export default compose(

Vous avez atteint l'estimation la plus précise.

)} - {!noUserInput && {children}} + {!isEmpty(previousAnswers) && ( + + )} ) } diff --git a/source/components/TargetSelection.js b/source/components/TargetSelection.js index 144f54650..e7c542246 100644 --- a/source/components/TargetSelection.js +++ b/source/components/TargetSelection.js @@ -1,6 +1,5 @@ import classNames from 'classnames' import InputSuggestions from 'Components/conversation/InputSuggestions' -import PeriodSwitch from 'Components/PeriodSwitch' import withColours from 'Components/utils/withColours' import withLanguage from 'Components/utils/withLanguage' import { encodeRuleName, findRuleByDottedName } from 'Engine/rules' @@ -16,22 +15,22 @@ import { analysisWithDefaultsSelector, blockingInputControlsSelector, flatRulesSelector, - noUserInputSelector, - situationBranchesSelector + noUserInputSelector } from 'Selectors/analyseSelectors' import { normalizeBasePath } from '../utils' import AnimatedTargetValue from './AnimatedTargetValue' +import Controls from './Controls' import CurrencyInput from './CurrencyInput/CurrencyInput' import ProgressCircle from './ProgressCircle' import './TargetSelection.css' export default compose( translate(), + withColours, reduxForm({ form: 'conversation', destroyOnUnmount: false }), - withColours, withRouter, connect( state => ({ @@ -43,7 +42,7 @@ export default compose( noUserInput: noUserInputSelector(state), conversationStarted: state.conversationStarted, activeInput: state.activeTargetInput, - mainTargetNames: state.simulationConfig.objectifs + objectifs: state?.simulationConfig?.objectifs || [] }), dispatch => ({ setFormValue: (field, name) => @@ -55,9 +54,13 @@ export default compose( )( class TargetSelection extends Component { render() { - let { colours } = this.props + let { + colours, + analysis: { controls } + } = this.props return (
+
{this.renderOutputList()}
-
) } renderOutputList() { - let displayedTargets = this.props.mainTargetNames.map(target => + let displayedTargets = this.props.objectifs.map(target => findRuleByDottedName(this.props.flatRules, target) ), { @@ -86,8 +88,7 @@ export default compose( analysis, noUserInput, blockingInputControls, - match, - keepFormValues + match } = this.props, targets = analysis ? analysis.targets : [] @@ -109,13 +110,11 @@ export default compose( @@ -189,7 +188,6 @@ let TargetInputOrValue = withLanguage( setActiveInput, language, noUserInput, - keepFormValues, blockingInputControls }) => ( @@ -206,7 +204,6 @@ let TargetInputOrValue = withLanguage( target, activeInput, setActiveInput, - keepFormValues, noUserInput, blockingInputControls }} @@ -218,26 +215,19 @@ let TargetInputOrValue = withLanguage( ) const TargetValue = connect( - state => ({ situation: situationBranchesSelector(state) }), + null, dispatch => ({ setFormValue: (field, name) => dispatch(change('conversation', field, name)) }) )( class TargetValue extends Component { render() { - let { - targets, - target, - noUserInput, - blockingInputControls, - situation - } = this.props + let { targets, target, noUserInput, blockingInputControls } = this.props + let targetWithValue = targets && targets.find(propEq('dottedName', target.dottedName)), - value = - situation[target.dottedName] || - (targetWithValue && targetWithValue.nodeValue) - console.log(target.dottedName, situation[target.dottedName]) + value = targetWithValue && targetWithValue.nodeValue + return (
{ if (!target.question) return if (value != null) setFormValue(target.dottedName, Math.floor(value) + '') - if (activeInput && !keepFormValues) setFormValue(activeInput, '') + if (activeInput) setFormValue(activeInput, '') setActiveInput(target.dottedName) } } diff --git a/source/components/simulationConfigs/assimilé.yaml b/source/components/simulationConfigs/assimilé.yaml index e82182c1d..47b7ce19a 100644 --- a/source/components/simulationConfigs/assimilé.yaml +++ b/source/components/simulationConfigs/assimilé.yaml @@ -8,6 +8,10 @@ objectifs: - entreprise . chiffre d'affaires - entreprise . charges - revenu disponible +questions: + blacklist: + - entreprise . chiffre d'affaires + - revenu disponible situation: micro entreprise: non indépendant: non diff --git a/source/components/ui/index.css b/source/components/ui/index.css index 1f94a4cfd..22bcb55be 100644 --- a/source/components/ui/index.css +++ b/source/components/ui/index.css @@ -69,7 +69,8 @@ span.ui__.enumeration:not(:last-of-type)::after { color: white; font-weight: 500; border-radius: 1em; - padding: .1em .5em; + padding: 0.1em 0.5em; + margin: 1rem; font-size: 1rem; vertical-align: middle; } diff --git a/source/règles/base.yaml b/source/règles/base.yaml index 85f20a964..09c4d5b1a 100644 --- a/source/règles/base.yaml +++ b/source/règles/base.yaml @@ -2551,6 +2551,7 @@ - nom: revenu disponible titre: Revenu disponible (net de cotisations et d'impôt) période: flexible + question: Quel revenu voulez-vous toucher ? formule: revenu net d'impôt - entreprise . charges non déductibles - espace: entreprise @@ -2611,6 +2612,7 @@ inversion: avec: - revenu brut + - revenu disponible - espace: indépendant nom: revenu brut diff --git a/source/selectors/analyseSelectors.js b/source/selectors/analyseSelectors.js index 7ae822192..2a4c88281 100644 --- a/source/selectors/analyseSelectors.js +++ b/source/selectors/analyseSelectors.js @@ -186,6 +186,7 @@ let analysisValidatedOnlySelector = makeAnalysisSelector( export let blockingInputControlsSelector = state => { let analysis = analysisWithDefaultsSelector(state) + console.log('analysis blocked', analysis.blockingInputControls) return analysis && analysis.blockingInputControls } diff --git a/source/selectors/regleSelectors.js b/source/selectors/regleSelectors.js index 576d3a37e..90f670764 100644 --- a/source/selectors/regleSelectors.js +++ b/source/selectors/regleSelectors.js @@ -69,7 +69,13 @@ export const règleValeurSelector = createSelector( : Array.isArray(situation) ? situation[0][dottedName] : situation[dottedName] - + console.log( + dottedName, + valeur, + situation, + analysis.cache, + analysis.cache[dottedName] + ) if (isNil(valeur)) { console.warn( `[règleValeurSelector] Impossible de trouver la valeur associée à la règle "${dottedName}". Pensez à vérifier l'orthographe et que l'écriture est bien sous forme dottedName. Vérifiez aussi qu'il ne manque pas une valeur par défaut à une règle nécessaire au calcul.` diff --git a/source/sites/mycompanyinfrance.fr/App.js b/source/sites/mycompanyinfrance.fr/App.js index 840ad5c15..9d6829deb 100644 --- a/source/sites/mycompanyinfrance.fr/App.js +++ b/source/sites/mycompanyinfrance.fr/App.js @@ -7,10 +7,6 @@ import { withNamespaces } from 'react-i18next' import { Route, Switch } from 'react-router-dom' import 'Ui/index.css' import Provider from '../../Provider' -import { - persistEverything, - retrievePersistedState -} from '../../storage/persistEverything' import ReactPiwik from '../../Tracker' import './App.css' import Footer from './layout/Footer/Footer' @@ -57,8 +53,7 @@ class InFranceRoute extends Component { language={this.props.language} tracker={tracker} reduxMiddlewares={middlewares} - initialStore={{ ...retrievePersistedState(), lang: 'en' }} - onStoreCreated={persistEverything}> + initialStore={{ lang: 'en' }}>
diff --git a/source/sites/mycompanyinfrance.fr/pages/SocialSecurity/AssimiléSalarié.js b/source/sites/mycompanyinfrance.fr/pages/SocialSecurity/AssimiléSalarié.js index fe1b24ea9..029efe9fb 100644 --- a/source/sites/mycompanyinfrance.fr/pages/SocialSecurity/AssimiléSalarié.js +++ b/source/sites/mycompanyinfrance.fr/pages/SocialSecurity/AssimiléSalarié.js @@ -27,7 +27,7 @@ const AssimiléSalarié = () => ( quelques exceptions près (chômage en moins).

- + ) diff --git a/source/sites/mycompanyinfrance.fr/sitePaths.js b/source/sites/mycompanyinfrance.fr/sitePaths.js index fb3f8fc41..604e78788 100644 --- a/source/sites/mycompanyinfrance.fr/sitePaths.js +++ b/source/sites/mycompanyinfrance.fr/sitePaths.js @@ -82,6 +82,9 @@ const constructLocalizedSitePath = language => { }, démarcheEmbauche: { index: t('path.démarcheEmbauche.index', '/démarches-embauche') + }, + documentation: { + index: t('path.documentation.index', '/documentation') } }) } diff --git a/source/storage/persistEverything.js b/source/storage/persistEverything.js index 05860cdf2..3afce7fa4 100644 --- a/source/storage/persistEverything.js +++ b/source/storage/persistEverything.js @@ -3,6 +3,7 @@ import type { Store } from 'redux' import { debounce } from '../utils' import safeLocalStorage from './safeLocalStorage' +import { omit } from 'ramda'; import type { State } from 'Types/State' import type { Action } from 'Types/ActionsTypes' @@ -10,10 +11,13 @@ const VERSION = 1 const LOCAL_STORAGE_KEY = 'mycompanyinfrance::persisted-everything:v' + VERSION -export function persistEverything(store: Store) { +type OptionsType = { + except: Array +} +export const persistEverything = ({ except = [] }:OptionsType) => (store: Store): void => { const listener = () => { const state = store.getState() - safeLocalStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(state)) + safeLocalStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(omit(except, state))) } store.subscribe(debounce(1000, listener)) }