Refactorisation de code

On évite de passer des composants React en props

Fixes #146
pull/206/head
mama 2018-02-13 17:48:18 +01:00 committed by Laurent Bossavit
parent b57cbe444a
commit db02569d14
4 changed files with 27 additions and 34 deletions

View File

@ -51,7 +51,7 @@
"react-virtualized-select": "^3.1.0",
"reduce-reducers": "^0.1.2",
"redux": "^3.7.2",
"redux-form": "6.8.0",
"redux-form": "^7.2.3",
"reselect": "^3.0.1",
"screenfull": "^3.3.2",
"whatwg-fetch": "^2.0.3",
@ -66,7 +66,7 @@
"@babel/preset-react": "^7.0.0-beta.34",
"akh": "^3.1.2",
"autoprefixer": "^7.2.4",
"babel-eslint": "^8.1.2",
"babel-eslint": "^8.2.1",
"babel-loader": "8.0.0-beta.0",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-plugin-transform-class-properties": "^6.24.1",
@ -78,8 +78,8 @@
"css-loader": "^0.28.1",
"csv-loader": "^2.1.1",
"daggy": "^1.1.0",
"eslint": "^4.14.0",
"eslint-plugin-react": "^7.5.1",
"eslint": "^4.17.0",
"eslint-plugin-react": "^7.6.1",
"express": "^4.15.3",
"fantasy-combinators": "0.0.1",
"fantasy-land": "^3.3.0",

View File

@ -15,8 +15,6 @@ import {
import './conversation/conversation.css'
import './Simulateur.css'
import Conversation from './conversation/Conversation'
import { getInputComponent } from 'Engine/generateQuestions'
import ReactPiwik from './Tracker'
import Results from 'Components/Results'
@ -105,21 +103,10 @@ export default class extends Component {
<Conversation
{...{
reinitalise,
currentQuestion:
currentQuestion &&
getInputComponent({ unfolded: true })(
flatRules,
this.targetNames
)(currentQuestion),
foldedSteps: map(
getInputComponent({ unfolded: false })(
flatRules,
this.targetNames
),
foldedSteps
),
done: this.props.done,
nextSteps: this.props.nextSteps,
parsedRules,
targetNames: this.targetNames,
currentQuestion,
foldedSteps,
textColourOnWhite: themeColours.textColourOnWhite
}}
/>

View File

@ -1,10 +1,11 @@
import React, { Component } from 'react'
import { Trans, translate } from 'react-i18next'
import { isEmpty } from 'ramda'
import { isEmpty, map } from 'ramda'
import Aide from '../Aide'
import Satisfaction from '../Satisfaction'
import { reduxForm } from 'redux-form'
import { scroller, Element } from 'react-scroll'
import { getInputComponent } from 'Engine/generateQuestions'
import Satisfaction from '../Satisfaction'
let scroll = () =>
scroller.scrollTo('myScrollToElement', {
@ -29,10 +30,10 @@ export default class Conversation extends Component {
let {
foldedSteps,
currentQuestion,
parsedRules,
targetNames,
reinitalise,
textColourOnWhite,
done,
nextSteps
textColourOnWhite
} = this.props
return (
@ -42,13 +43,15 @@ export default class Conversation extends Component {
<div className="header">
<button
onClick={reinitalise}
style={{ color: textColourOnWhite }}
>
style={{ color: textColourOnWhite }}>
<i className="fa fa-trash" aria-hidden="true" />
<Trans i18nKey="resetAll">Tout effacer</Trans>
</button>
</div>
{foldedSteps}
{map(
getInputComponent({ unfolded: false })(parsedRules, targetNames),
foldedSteps
)}
</div>
)}
<Element name="myScrollToElement" id="myScrollToElement">
@ -57,13 +60,18 @@ export default class Conversation extends Component {
style={{
opacity: foldedSteps.length != 0 ? 1 : 0,
color: textColourOnWhite
}}
>
}}>
<i className="fa fa-long-arrow-up" aria-hidden="true" />
<Trans i18nKey="change">Modifier mes réponses</Trans>
</h3>
<div id="currentQuestion">
{currentQuestion || <Satisfaction simu={this.props.simu} />}
{currentQuestion ? (
getInputComponent({ unfolded: true })(parsedRules, targetNames)(
currentQuestion
)
) : (
<Satisfaction />
)}
</div>
</Element>
<Aide />

View File

@ -23,8 +23,6 @@ export var FormDecorator = formType => RenderField =>
//... this helper directly to the redux state to avoid passing more props
state => ({
themeColours: state.themeColours,
getCurrentInversion: dottedName =>
formValueSelector('conversation')(state, 'inversions.' + dottedName),
situationGate: state.situationGate
}),
dispatch => ({