mon-entreprise/source/components/Controls.js

68 lines
1.7 KiB
JavaScript
Raw Normal View History

import React from 'react'
import './Controls.css'
import emoji from 'react-easy-emoji'
import { connect } from 'react-redux'
import { startConversation } from 'Actions/actions'
import { animated, Spring } from 'react-spring'
2018-09-12 13:07:46 +00:00
import { makeJsx } from 'Engine/evaluation'
function Controls({ blockingInputControls, controls, startConversation }) {
return (
2018-09-11 15:33:11 +00:00
<div id="controlsBlock">
{blockingInputControls && (
<p className="blockingControl">{blockingInputControls[0].message}</p>
)}
{!blockingInputControls && (
<Spring
to={{
height: controls?.length ? 'auto' : 0,
opacity: controls?.length ? 1 : 0
}}
native>
{styles =>
controls?.length ? (
<animated.div id="control" style={styles}>
<div id="controlContent">
{do {
2018-09-12 13:07:46 +00:00
let { level, solution, evaluated } = controls[0]
;<>
<h3
style={{
borderBottomColor:
level === 'avertissement' ? '#e67e22' : '#34495e'
}}>
2018-09-12 13:07:46 +00:00
{level === 'avertissement'
2018-09-12 15:07:38 +00:00
? 'Attention'
2018-09-12 13:07:46 +00:00
: 'Information'}
</h3>
<p id="controlExplanation">{makeJsx(evaluated)}</p>
2018-09-12 13:07:46 +00:00
{solution && (
<div id="solution">
{emoji('💡')}
<button
key={solution.cible}
className="ui__ link-button"
onClick={() => startConversation(solution.cible)}>
{solution.texte}
</button>
</div>
)}
</>
}}
</div>
</animated.div>
) : null
}
</Spring>
)}
</div>
)
}
export default connect(
(state, props) => ({ key: props.language }),
{
startConversation
}
)(Controls)