⚙️ Simplifier Conversation, construire dans Simulateur
parent
66bef87122
commit
353d9711ec
|
@ -72,6 +72,16 @@ export default class extends Component {
|
|||
},
|
||||
title = sim('titre') || capitalise0(this.rule['titre'] || this.rule['nom'])
|
||||
|
||||
let buildStep = accessor => step =>
|
||||
<step.component
|
||||
key={step.name}
|
||||
{...step}
|
||||
step={step}
|
||||
answer={accessor(step.name)}
|
||||
/>
|
||||
|
||||
let currentQuestion = R.head(unfoldedSteps)
|
||||
|
||||
return (
|
||||
<div id="sim" className={classNames({started})}>
|
||||
<Helmet>
|
||||
|
@ -98,7 +108,12 @@ export default class extends Component {
|
|||
}
|
||||
{ (started || !sim(['introduction', 'notes'])) &&
|
||||
<Conversation initialValues={ R.pathOr({},['simulateur','par défaut'], sim) }
|
||||
{...{foldedSteps, unfoldedSteps, extraSteps, reinitalise, situation, situationGate, textColourOnWhite: themeColours.textColourOnWhite}}/>
|
||||
{...{
|
||||
reinitalise,
|
||||
foldedSteps: R.map(buildStep(situation), foldedSteps),
|
||||
currentQuestion: currentQuestion && buildStep(situation)({...currentQuestion, unfolded: true}),
|
||||
extraSteps: R.map(buildStep(situationGate), extraSteps),
|
||||
textColourOnWhite: themeColours.textColourOnWhite}}/>
|
||||
}
|
||||
|
||||
</div>
|
||||
|
|
|
@ -11,16 +11,7 @@ import Scroll from 'react-scroll'
|
|||
})
|
||||
export default class Conversation extends Component {
|
||||
render() {
|
||||
let {foldedSteps, unfoldedSteps, extraSteps, reinitalise, situation, situationGate, textColourOnWhite} = this.props,
|
||||
currentQuestion = R.head(unfoldedSteps) ? R.head(unfoldedSteps) : null
|
||||
|
||||
let buildStep = accessor => step =>
|
||||
<step.component
|
||||
key={step.name}
|
||||
{...step}
|
||||
step={step}
|
||||
answer={accessor(step.name)}
|
||||
/>
|
||||
let {foldedSteps, currentQuestion, extraSteps, reinitalise, textColourOnWhite} = this.props
|
||||
|
||||
Scroll.animateScroll.scrollToBottom()
|
||||
return (
|
||||
|
@ -35,25 +26,22 @@ export default class Conversation extends Component {
|
|||
Tout effacer
|
||||
</button>
|
||||
</div>
|
||||
{foldedSteps.map(buildStep(situation))}
|
||||
{foldedSteps}
|
||||
</div>
|
||||
}
|
||||
{unfoldedSteps.length == 0 &&
|
||||
{!currentQuestion &&
|
||||
<Conclusion affiner={!R.isEmpty(extraSteps)}/>}
|
||||
{ !R.isEmpty(extraSteps) &&
|
||||
<div id="foldedSteps">
|
||||
<div className="header" >
|
||||
<h3>Affiner votre situation</h3>
|
||||
</div>
|
||||
{extraSteps.map(buildStep(situationGate))}
|
||||
{extraSteps}
|
||||
</div>
|
||||
}
|
||||
<div id="unfoldedSteps">
|
||||
{ currentQuestion && buildStep(situation)({...currentQuestion, unfolded: true})}
|
||||
<div id="currentQuestion">
|
||||
{ currentQuestion || <Satisfaction simu={this.props.simu}/>}
|
||||
</div>
|
||||
{!currentQuestion &&
|
||||
<Satisfaction simu={this.props.simu}/>
|
||||
}
|
||||
</div>
|
||||
<Aide />
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue