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'
|
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-11-07 19:46:40 +01:00
|
|
|
analysis: state.analysis,
|
|
|
|
targetName: state.targetName,
|
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 {
|
2017-11-07 19:46:40 +01:00
|
|
|
analysis,
|
|
|
|
targetName,
|
2017-05-18 12:07:17 +02:00
|
|
|
conversationStarted,
|
2017-11-15 11:12:58 +01:00
|
|
|
conversationFirstAnswer,
|
2017-05-18 12:07:17 +02:00
|
|
|
location
|
2017-08-21 15:39:54 +02:00
|
|
|
} = this.props
|
|
|
|
|
2017-11-07 19:46:40 +01:00
|
|
|
if (!analysis) return null
|
2017-05-18 12:07:17 +02:00
|
|
|
|
2017-11-07 19:46:40 +01:00
|
|
|
let {targets} = analysis
|
|
|
|
|
|
|
|
clearDict() // pourquoi ??
|
2017-03-16 19:30:30 +01:00
|
|
|
|
2017-10-18 18:32:13 +02:00
|
|
|
let onRulePage = R.contains('/regle/')(location.pathname)
|
2017-01-10 19:22:44 +01:00
|
|
|
return (
|
2017-11-15 11:12:58 +01:00
|
|
|
<section ref={el => this.el = el} id="results">
|
2017-05-18 12:07:17 +02:00
|
|
|
{onRulePage && conversationStarted ?
|
|
|
|
<div id ="results-actions">
|
2017-11-07 19:46:40 +01:00
|
|
|
<Link id="toSimulation" to={'/simu/' + encodeRuleName(targetName)}>
|
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-11-07 19:46:40 +01:00
|
|
|
<h2><i className="fa fa-calculator" aria-hidden="true"></i>{targets.length == 1 ? 'Votre résultat' : 'Vos résultats'}<span>·</span><small>Cliquez pour comprendre chaque calcul</small></h2>
|
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-11-07 19:46:40 +01:00
|
|
|
{targets.map( rule => <li key={rule.nom}>
|
2017-10-19 16:02:37 +02:00
|
|
|
<RuleValueVignette {...rule} conversationStarted={conversationStarted} />
|
|
|
|
</li>)}
|
2017-01-10 19:22:44 +01:00
|
|
|
</ul>
|
|
|
|
</section>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|