2017-07-02 19:12:02 +02:00
|
|
|
import R from 'ramda'
|
2017-01-10 19:22:44 +01:00
|
|
|
import React, { Component } from 'react'
|
2017-02-09 13:58:12 +01:00
|
|
|
import classNames from 'classnames'
|
2017-04-18 19:37:38 +02:00
|
|
|
import {Link} from 'react-router-dom'
|
2017-03-15 16:26:00 +01:00
|
|
|
import {connect} from 'react-redux'
|
2017-05-18 12:07:17 +02:00
|
|
|
import { withRouter } from 'react-router'
|
2017-07-02 19:12:02 +02:00
|
|
|
|
2017-03-27 15:32:03 +02:00
|
|
|
import './Results.css'
|
2017-10-03 11:44:03 +02:00
|
|
|
import {clearDict} from 'Engine/traverse'
|
2017-07-07 10:35:40 +02:00
|
|
|
import {encodeRuleName} from 'Engine/rules'
|
|
|
|
import {getObjectives} from 'Engine/generateQuestions'
|
2017-10-03 15:04:41 +02:00
|
|
|
import RuleValueVignette from './rule/RuleValueVignette'
|
2017-05-18 12:07:17 +02:00
|
|
|
|
|
|
|
@withRouter
|
2017-03-15 16:26:00 +01:00
|
|
|
@connect(
|
|
|
|
state => ({
|
2017-04-18 19:37:38 +02:00
|
|
|
analysedSituation: state.analysedSituation,
|
2017-05-18 15:01:34 +02:00
|
|
|
conversationStarted: !R.isEmpty(state.form),
|
2017-07-17 14:02:07 +02:00
|
|
|
conversationFirstAnswer: R.path(['form', 'conversation', 'values'])(state),
|
2017-09-21 15:46:59 +02:00
|
|
|
situationGate: state.situationGate
|
2017-03-15 16:26:00 +01:00
|
|
|
})
|
|
|
|
)
|
2017-01-10 19:22:44 +01:00
|
|
|
export default class Results extends Component {
|
|
|
|
render() {
|
2017-05-18 12:07:17 +02:00
|
|
|
let {
|
|
|
|
analysedSituation,
|
|
|
|
conversationStarted,
|
2017-05-18 15:01:34 +02:00
|
|
|
conversationFirstAnswer: showResults,
|
2017-07-17 14:02:07 +02:00
|
|
|
situationGate,
|
2017-05-18 12:07:17 +02:00
|
|
|
location
|
2017-08-21 15:39:54 +02:00
|
|
|
} = this.props
|
|
|
|
|
2017-08-22 11:38:11 +02:00
|
|
|
|
|
|
|
let explanation = R.has('root', analysedSituation) && clearDict() && getObjectives(situationGate, analysedSituation.root, analysedSituation.parsedRules)
|
2017-05-18 12:07:17 +02:00
|
|
|
|
2017-03-16 19:30:30 +01:00
|
|
|
if (!explanation) return null
|
|
|
|
|
2017-05-18 12:07:17 +02:00
|
|
|
let onRulePage = R.contains('/regle/')(location.pathname)
|
2017-05-18 15:01:34 +02:00
|
|
|
|
2017-01-10 19:22:44 +01:00
|
|
|
return (
|
2017-05-18 15:01:34 +02:00
|
|
|
<section id="results" className={classNames({show: showResults})}>
|
2017-05-18 12:07:17 +02:00
|
|
|
{onRulePage && conversationStarted ?
|
|
|
|
<div id ="results-actions">
|
2017-07-13 09:49:18 +02:00
|
|
|
<Link id="toSimulation" to={"/simu/" + encodeRuleName(analysedSituation.root.name)}>
|
2017-05-18 12:07:17 +02:00
|
|
|
<i className="fa fa-arrow-circle-left" aria-hidden="true"></i>Reprendre la simulation
|
|
|
|
</Link>
|
|
|
|
</div>
|
2017-10-03 11:44:03 +02:00
|
|
|
: <div id="results-titles">
|
2017-05-18 12:07:17 +02:00
|
|
|
<h2>Vos résultats <i className="fa fa-hand-o-right" aria-hidden="true"></i></h2>
|
2017-07-13 09:49:18 +02:00
|
|
|
{do {let text = R.path(['simulateur', 'résultats'])(analysedSituation.root)
|
2017-05-18 12:07:17 +02:00
|
|
|
text &&
|
|
|
|
<p id="resultText">{text}</p>
|
2017-05-30 11:08:10 +02:00
|
|
|
}}
|
|
|
|
<p id="understandTip"><i className="fa fa-lightbulb-o" aria-hidden="true"></i><em>Cliquez pour comprendre chaque calcul</em></p>
|
2017-10-03 11:44:03 +02:00
|
|
|
</div>
|
2017-05-18 12:07:17 +02:00
|
|
|
}
|
2017-01-10 19:22:44 +01:00
|
|
|
<ul>
|
2017-10-03 11:44:03 +02:00
|
|
|
{explanation.map( rule => <RuleValueVignette key={rule.nom} {...rule} conversationStarted={conversationStarted} />)}
|
2017-01-10 19:22:44 +01:00
|
|
|
</ul>
|
|
|
|
</section>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|