2018-06-29 16:14:00 +00:00
|
|
|
|
import React from 'react'
|
|
|
|
|
import './Controls.css'
|
2018-09-11 14:14:46 +00:00
|
|
|
|
import emoji from 'react-easy-emoji'
|
|
|
|
|
import { connect } from 'react-redux'
|
|
|
|
|
import { startConversation } from 'Actions/actions'
|
2018-09-11 16:45:54 +00:00
|
|
|
|
import { animated, Spring } from 'react-spring'
|
2018-09-12 13:07:46 +00:00
|
|
|
|
import { makeJsx } from 'Engine/evaluation'
|
2018-09-12 15:49:50 +00:00
|
|
|
|
import { createMarkdownDiv } from 'Engine/marked'
|
2018-09-12 17:12:59 +00:00
|
|
|
|
import { currentQuestionSelector } from '../selectors/analyseSelectors'
|
|
|
|
|
import { reject } from 'ramda'
|
2018-10-02 14:52:27 +00:00
|
|
|
|
import withColours from './utils/withColours'
|
2018-09-12 17:12:59 +00:00
|
|
|
|
|
|
|
|
|
function Controls({
|
|
|
|
|
blockingInputControls,
|
|
|
|
|
controls,
|
|
|
|
|
startConversation,
|
2018-09-13 13:55:55 +00:00
|
|
|
|
currentQuestion,
|
2018-10-02 14:52:27 +00:00
|
|
|
|
foldedSteps,
|
|
|
|
|
colours
|
2018-09-12 17:12:59 +00:00
|
|
|
|
}) {
|
2018-09-11 14:14:46 +00:00
|
|
|
|
return (
|
2018-09-11 15:33:11 +00:00
|
|
|
|
<div id="controlsBlock">
|
2018-09-11 14:14:46 +00:00
|
|
|
|
{blockingInputControls && (
|
2018-09-11 16:45:54 +00:00
|
|
|
|
<p className="blockingControl">{blockingInputControls[0].message}</p>
|
|
|
|
|
)}
|
2018-10-02 14:52:27 +00:00
|
|
|
|
{!blockingInputControls && (
|
|
|
|
|
<>
|
|
|
|
|
<ul>
|
|
|
|
|
{controls.map(control => (
|
|
|
|
|
<li
|
|
|
|
|
key={control.si}
|
|
|
|
|
className="control"
|
|
|
|
|
style={{ background: colours.lightenColour(45) }}>
|
2018-09-12 15:33:27 +00:00
|
|
|
|
{do {
|
2018-09-12 15:49:50 +00:00
|
|
|
|
let { level, message, solution, evaluated } = control
|
2018-09-12 15:33:27 +00:00
|
|
|
|
;<>
|
2018-10-02 14:52:27 +00:00
|
|
|
|
{emoji(level == 'avertissement' ? '⚠️' : 'ℹ️')}
|
|
|
|
|
<div className="controlText">
|
|
|
|
|
{message && createMarkdownDiv(message)}
|
|
|
|
|
{!message && (
|
|
|
|
|
<span id="controlExplanation">
|
|
|
|
|
{makeJsx(evaluated)}
|
|
|
|
|
</span>
|
2018-09-13 13:55:55 +00:00
|
|
|
|
)}
|
2018-10-02 14:52:27 +00:00
|
|
|
|
{solution &&
|
|
|
|
|
!foldedSteps.includes(solution.cible) && (
|
|
|
|
|
<div id="solution">
|
|
|
|
|
{/*emoji('💡')*/}
|
|
|
|
|
<button
|
|
|
|
|
key={solution.cible}
|
|
|
|
|
className="ui__ link-button"
|
|
|
|
|
onClick={() => startConversation(solution.cible)}>
|
|
|
|
|
{solution.texte}
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
2018-09-12 15:33:27 +00:00
|
|
|
|
</>
|
|
|
|
|
}}
|
2018-10-02 14:52:27 +00:00
|
|
|
|
</li>
|
|
|
|
|
))}
|
|
|
|
|
</ul>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
2018-09-11 14:14:46 +00:00
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default connect(
|
2018-09-12 17:12:59 +00:00
|
|
|
|
(state, props) => ({
|
|
|
|
|
currentQuestion: currentQuestionSelector(state),
|
2018-09-13 13:55:55 +00:00
|
|
|
|
foldedSteps: state.conversationSteps.foldedSteps,
|
2018-09-12 17:12:59 +00:00
|
|
|
|
key: props.language
|
|
|
|
|
}),
|
2018-09-11 14:14:46 +00:00
|
|
|
|
{
|
|
|
|
|
startConversation
|
|
|
|
|
}
|
2018-10-02 14:52:27 +00:00
|
|
|
|
)(withColours(Controls))
|