From fd280b2e065d87525546d1a6fc177de6dd6b8687 Mon Sep 17 00:00:00 2001 From: Johan Girod Date: Tue, 8 Jan 2019 20:43:57 +0100 Subject: [PATCH] wip --- source/components/ComparativeTargets.js | 30 +++++++++---------- source/components/TargetSelection.js | 2 +- source/components/Targets.js | 14 ++++----- .../components/simulationConfigs/salarié.yaml | 5 +++- source/selectors/analyseSelectors.js | 7 ++++- source/selectors/ficheDePaieSelectors.js | 5 ++-- source/selectors/regleSelectors.js | 2 +- 7 files changed, 36 insertions(+), 29 deletions(-) diff --git a/source/components/ComparativeTargets.js b/source/components/ComparativeTargets.js index 1f8a0c7d7..ca40a0e35 100644 --- a/source/components/ComparativeTargets.js +++ b/source/components/ComparativeTargets.js @@ -1,18 +1,18 @@ -import React from 'react' -import { - flatRulesSelector, - analysisWithDefaultsSelector -} from 'Selectors/analyseSelectors' -import { connect } from 'react-redux' -import './ComparativeTargets.css' -import withColours from 'Components/utils/withColours' -import { Link } from 'react-router-dom' -import emoji from 'react-easy-emoji' -import { compose } from 'ramda' -import AnimatedTargetValue from './AnimatedTargetValue' import PeriodSwitch from 'Components/PeriodSwitch' +import withColours from 'Components/utils/withColours' import { findRuleByDottedName } from 'Engine/rules' +import { compose } from 'ramda' +import React from 'react' +import emoji from 'react-easy-emoji' +import { connect } from 'react-redux' +import { Link } from 'react-router-dom' import { formValueSelector } from 'redux-form' +import { + analysisListWithDefaultsSelector, + flatRulesSelector +} from 'Selectors/analyseSelectors' +import AnimatedTargetValue from './AnimatedTargetValue' +import './ComparativeTargets.css' export default compose( connect( state => ({ @@ -21,7 +21,7 @@ export default compose( state.simulationConfig?.objectifs[0] ), simulationBranches: state.simulationConfig?.branches, - analyses: analysisWithDefaultsSelector(state), + analyses: analysisListWithDefaultsSelector(state), chiffreAffaires: formValueSelector('conversation')( state, "entreprise . chiffre d'affaires" @@ -43,8 +43,8 @@ export default compose( chiffreAffaires, simulationBranches } = this.props - if(!simulationBranches) { - return null; + if (!simulationBranches) { + return null } return (
diff --git a/source/components/TargetSelection.js b/source/components/TargetSelection.js index c8e17e57d..90ced62f1 100644 --- a/source/components/TargetSelection.js +++ b/source/components/TargetSelection.js @@ -84,7 +84,7 @@ export default compose( conversationStarted, activeInput, setActiveInput, - analysis, + analysis: analysis, noUserInput, blockingInputControls, match diff --git a/source/components/Targets.js b/source/components/Targets.js index ed6afe1fe..9f8b622c7 100644 --- a/source/components/Targets.js +++ b/source/components/Targets.js @@ -1,11 +1,11 @@ -import React from 'react' -import { analysisWithDefaultsSelector } from 'Selectors/analyseSelectors' -import { connect } from 'react-redux' -import './Targets.css' import withColours from 'Components/utils/withColours' -import { Link } from 'react-router-dom' -import emoji from 'react-easy-emoji' import { compose } from 'ramda' +import React from 'react' +import emoji from 'react-easy-emoji' +import { connect } from 'react-redux' +import { Link } from 'react-router-dom' +import { analysisWithDefaultsSelector } from 'Selectors/analyseSelectors' +import './Targets.css' export default compose( connect(state => ({ analysis: analysisWithDefaultsSelector(state) })), withColours @@ -17,7 +17,7 @@ export default compose( nodeValue, unité: unit, dottedName - } = this.props.analysis.targets[0] + } = this.props.analysis[0].targets[0] return (
diff --git a/source/components/simulationConfigs/salarié.yaml b/source/components/simulationConfigs/salarié.yaml index f6af8fa60..796c5de32 100644 --- a/source/components/simulationConfigs/salarié.yaml +++ b/source/components/simulationConfigs/salarié.yaml @@ -1,5 +1,8 @@ -objectifs: +objectifs: - contrat salarié . rémunération . total - contrat salarié . salaire . brut de base - contrat salarié . salaire . net - contrat salarié . salaire . net après impôt +situation: + contrat salarié: non + contrat salarié . assimilé salarié: non diff --git a/source/selectors/analyseSelectors.js b/source/selectors/analyseSelectors.js index b5256a8be..11fe6e73f 100644 --- a/source/selectors/analyseSelectors.js +++ b/source/selectors/analyseSelectors.js @@ -177,9 +177,14 @@ let makeAnalysisSelector = situationSelector => } ) -export let analysisWithDefaultsSelector = makeAnalysisSelector( +export let analysisListWithDefaultsSelector = makeAnalysisSelector( situationsWithDefaultsSelector ) +export let analysisWithDefaultsSelector = createSelector( + [analysisListWithDefaultsSelector], + analysisList => analysisList[0] +) + let analysisValidatedOnlySelector = makeAnalysisSelector( validatedSituationBranchesSelector ) diff --git a/source/selectors/ficheDePaieSelectors.js b/source/selectors/ficheDePaieSelectors.js index 78d60a2ad..06e767f65 100644 --- a/source/selectors/ficheDePaieSelectors.js +++ b/source/selectors/ficheDePaieSelectors.js @@ -77,8 +77,7 @@ function brancheSelector(variable: VariableWithCotisation): Branche { ].map(p => path(p, variable)) return ( // $FlowFixMe - 'protection sociale . ' + - (branches.filter(Boolean)[0] || 'autres') + 'protection sociale . ' + (branches.filter(Boolean)[0] || 'autres') ) } @@ -157,7 +156,7 @@ function analysisToFicheDePaie( règleAvecMontant, règleAvecValeur, règleLocalisée, - analysis + [analysis] ): ?FicheDePaie { if (!analysis.cache) { return null diff --git a/source/selectors/regleSelectors.js b/source/selectors/regleSelectors.js index 3e3289edb..c1822e9b6 100644 --- a/source/selectors/regleSelectors.js +++ b/source/selectors/regleSelectors.js @@ -50,7 +50,7 @@ export const règleValeurSelector = createSelector( analysisWithDefaultsSelector, validatedSituationBranchesSelector, règleLocaliséeSelector, - (analysis: Analysis, situations, règleLocalisée: string => Règle) => ( + ([analysis]: Analysis, situations, règleLocalisée: string => Règle) => ( dottedName: string ): RègleValeur => { if (!analysis || !analysis.cache) {