mon-entreprise/source/components/Controls.js

44 lines
1007 B
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'
function Controls({ blockingInputControls, controls, startConversation }) {
return (
2018-09-11 15:33:11 +00:00
<div id="controlsBlock">
{blockingInputControls && (
2018-09-11 15:33:11 +00:00
<p id="blockingControl">{blockingInputControls[0].message}</p>
)}
{!blockingInputControls &&
controls.length > 0 && (
<>
{emoji('⚠️')}
2018-09-11 15:33:11 +00:00
<ul id="controls">
{controls.map(({ test, action }) => (
<li key={test}>
<p>{test}</p>
{action && (
<button
key={action.cible}
className="ui__ link-button"
onClick={() => startConversation(action.cible)}>
{action.texte}
</button>
)}
</li>
))}
</ul>
</>
)}
</div>
)
}
export default connect(
(state, props) => ({ key: props.language }),
{
startConversation
}
)(Controls)