Améliore les simulateurs indidividuels

indeps-démo
Johan Girod 2019-01-10 15:07:47 +01:00
parent 2b268e5111
commit dd8c5f89cf
10 changed files with 48 additions and 22 deletions

View File

@ -5,17 +5,16 @@
flex-wrap: wrap;
}
#comparative-targets ul {
width: 100%;
padding: 0;
display: flex;
justify-content: space-around;
/* align-items: center; */
flex-wrap: wrap;
}
#comparative-targets li {
margin: 1em;
margin: 0.8rem;
background: var(--colour);
padding: 1em;
width: 12em;
padding: 1rem;
width: 12rem;
display: flex;
flex-direction: column;
justify-content: space-between;

View File

@ -46,8 +46,7 @@ export default compose(
<p>Vous avez atteint l'estimation la plus précise.</p>
</>
)}
{!noUserInput && <Animate.fromBottom>{children}</Animate.fromBottom>}
{!noUserInput && <Animate.fromBottom> {children}</Animate.fromBottom>}
</>
)
}

View File

@ -16,7 +16,8 @@ import {
analysisWithDefaultsSelector,
blockingInputControlsSelector,
flatRulesSelector,
noUserInputSelector
noUserInputSelector,
situationBranchesSelector
} from 'Selectors/analyseSelectors'
import { normalizeBasePath } from '../utils'
import AnimatedTargetValue from './AnimatedTargetValue'
@ -85,7 +86,8 @@ export default compose(
analysis,
noUserInput,
blockingInputControls,
match
match,
keepFormValues
} = this.props,
targets = analysis ? analysis.targets : []
@ -107,11 +109,13 @@ export default compose(
<TargetInputOrValue
{...{
target,
targets,
activeInput,
setActiveInput,
setFormValue: this.props.setFormValue,
noUserInput,
keepFormValues,
blockingInputControls
}}
/>
@ -185,6 +189,7 @@ let TargetInputOrValue = withLanguage(
setActiveInput,
language,
noUserInput,
keepFormValues,
blockingInputControls
}) => (
<span className="targetInputOrValue">
@ -201,6 +206,7 @@ let TargetInputOrValue = withLanguage(
target,
activeInput,
setActiveInput,
keepFormValues,
noUserInput,
blockingInputControls
}}
@ -212,17 +218,26 @@ let TargetInputOrValue = withLanguage(
)
const TargetValue = connect(
null,
state => ({ situation: situationBranchesSelector(state) }),
dispatch => ({
setFormValue: (field, name) => dispatch(change('conversation', field, name))
})
)(
class TargetValue extends Component {
render() {
let { targets, target, noUserInput, blockingInputControls } = this.props
let {
targets,
target,
noUserInput,
blockingInputControls,
situation
} = this.props
let targetWithValue =
targets && targets.find(propEq('dottedName', target.dottedName)),
value = targetWithValue && targetWithValue.nodeValue
value =
situation[target.dottedName] ||
(targetWithValue && targetWithValue.nodeValue)
console.log(target.dottedName, situation[target.dottedName])
return (
<div
className={classNames({
@ -238,13 +253,19 @@ const TargetValue = connect(
)
}
showField(value) {
let { target, setFormValue, activeInput, setActiveInput } = this.props
let {
target,
setFormValue,
activeInput,
setActiveInput,
keepFormValues
} = this.props
return () => {
if (!target.question) return
if (value != null)
setFormValue(target.dottedName, Math.floor(value) + '')
if (activeInput) setFormValue(activeInput, '')
if (activeInput && !keepFormValues) setFormValue(activeInput, '')
setActiveInput(target.dottedName)
}
}

View File

@ -8,7 +8,6 @@ objectifs:
- entreprise . chiffre d'affaires
- entreprise . charges
- revenu disponible
situation:
micro entreprise: non
indépendant: non

View File

@ -5,9 +5,9 @@ titre: |
- L'impôt sur le revenu est calculé pour un célibataire sans enfants et sans autre revenu.
objectifs:
- entreprise . rémunération totale du dirigeant
- entreprise . chiffre d'affaires
- entreprise . charges
- revenu disponible
situation:
indépendant: oui
micro entreprise: non

View File

@ -11,6 +11,7 @@ questions:
- entreprise . chiffre d'affaires
- entreprise . catégorie d'activité
- entreprise . charges
branches:
- nom: Micro-entreprise
situation:

View File

@ -15,6 +15,7 @@ import { analyse, analyseMany, parseAll } from 'Engine/traverse'
import {
add,
contains,
difference,
dissoc,
equals,
head,
@ -226,12 +227,18 @@ export let missingVariablesByTargetSelector = createSelector(
export let nextStepsSelector = createSelector(
[
currentMissingVariablesByTargetSelector,
state => state.simulationConfig?.questions
state => state.simulationConfig?.questions,
state => state.simulationConfig?.objectifs
],
(mv, questions) => {
let nextSteps = getNextSteps(mv)
if (questions) return intersection(nextSteps, questions)
if (questions && questions.blacklist) {
return difference(nextSteps, questions.blacklist)
}
if (questions) {
return intersection(nextSteps, questions)
}
return nextSteps
}
)

View File

@ -27,7 +27,7 @@ const AssimiléSalarié = () => (
quelques exceptions près (chômage en moins).
</p>
<SimpleSimulation>
<TargetSelection />
<TargetSelection keepFormValues />
</SimpleSimulation>
</>
)

View File

@ -33,7 +33,7 @@ const Indépendant = () => (
professionnel peut souscrire volontairement des assurances spécifiques.
</p>
<SimpleSimulation>
<TargetSelection />
<TargetSelection keepFormValues />
</SimpleSimulation>
</>
)

View File

@ -27,7 +27,7 @@ const MicroEntreprise = () => (
professionnel peut souscrire volontairement des assurances spécifiques.
</p>
<SimpleSimulation>
<TargetSelection />
<TargetSelection keepFormValues />
</SimpleSimulation>
</>
)