Ajoute une inversion pour pouvoir partir du revenu disponible

indeps-démo
Johan Girod 2019-01-10 17:49:35 +01:00
parent dd8c5f89cf
commit 048be37a07
12 changed files with 57 additions and 57 deletions

View File

@ -185,7 +185,7 @@ export default compose(
/>
)}
</div>
{!location.pathname.endsWith('/simulation') && validInputEntered && (
{/* {!location.pathname.endsWith('/simulation') && validInputEntered && (
<Animate.fromBottom>
<div style={{ textAlign: 'center' }}>
{arePreviousAnswers && conversationStarted && (
@ -229,7 +229,7 @@ export default compose(
</h2>
<PaySlip />
</Animate.fromBottom>
)}
)} */}
</>
)
}

View File

@ -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) && (
<button
className="ui__ button small plain"
onClick={() => this.setState({ displayAnswers: true })}>
Mes réponses
</button>
)}
{this.state.displayAnswers && (
<Answers onClose={() => this.setState({ displayAnswers: false })} />
)}
<Animate.fromBottom> {children}</Animate.fromBottom>
<Conversation
textColourOnWhite={this.props.colours.textColourOnWhite}
/>
@ -46,7 +40,13 @@ export default compose(
<p>Vous avez atteint l'estimation la plus précise.</p>
</>
)}
{!noUserInput && <Animate.fromBottom> {children}</Animate.fromBottom>}
{!isEmpty(previousAnswers) && (
<button
className="ui__ button small plain"
onClick={() => this.setState({ displayAnswers: true })}>
Mes réponses
</button>
)}
</>
)
}

View File

@ -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 (
<div id="targetSelection">
<Controls {...{ controls }} />
<section
id="targetsContainer"
style={{
@ -70,13 +73,12 @@ export default compose(
}}>
{this.renderOutputList()}
</section>
<PeriodSwitch />
</div>
)
}
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(
<TargetInputOrValue
{...{
target,
targets,
activeInput,
setActiveInput,
setFormValue: this.props.setFormValue,
noUserInput,
keepFormValues,
blockingInputControls
}}
/>
@ -189,7 +188,6 @@ let TargetInputOrValue = withLanguage(
setActiveInput,
language,
noUserInput,
keepFormValues,
blockingInputControls
}) => (
<span className="targetInputOrValue">
@ -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 (
<div
className={classNames({
@ -253,19 +243,13 @@ const TargetValue = connect(
)
}
showField(value) {
let {
target,
setFormValue,
activeInput,
setActiveInput,
keepFormValues
} = this.props
let { target, setFormValue, activeInput, setActiveInput } = this.props
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)
}
}

View File

@ -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

View File

@ -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;
}

View File

@ -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

View File

@ -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
}

View File

@ -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.`

View File

@ -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' }}>
<TrackPageView />
<div id="content">
<RouterSwitch />

View File

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

View File

@ -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')
}
})
}

View File

@ -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<State, Action>) {
type OptionsType = {
except: Array<string>
}
export const persistEverything = ({ except = [] }:OptionsType) => (store: Store<State, Action>): 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))
}