Utilisation des selecteurs dans Sondage.js

pull/256/head
Mael 2018-06-13 17:34:33 +02:00
parent 163616bb4c
commit a86bcd8829
1 changed files with 17 additions and 9 deletions

View File

@ -7,13 +7,16 @@ import Smiley from './SatisfactionSmiley'
import TypeFormEmbed from './TypeFormEmbed'
import withLanguage from './withLanguage'
import { Trans, translate } from 'react-i18next'
import withColours from './withColours';
import withColours from './withColours'
import {
noUserInputSelector,
nextStepsSelector
} from 'Selectors/analyseSelectors'
@connect(state => ({
targets: state.analysis ? state.analysis.targets : [],
activeInput: state.activeTargetInput,
currentQuestion: state.currentQuestion,
conversationStarted: state.conversationStarted
conversationStarted: state.conversationStarted,
noUserInput: noUserInputSelector(state),
nextSteps: nextStepsSelector(state)
}))
@translate()
@withLanguage
@ -27,9 +30,9 @@ export default class Sondage extends Component {
static getDerivedStateFromProps(nextProps, currentState) {
let feedbackAlreadyAsked = !!document.cookie.includes('feedback_asked=true')
let conditions = {
AFTER_FIRST_ESTIMATE: nextProps.activeInput && nextProps.targets.length,
AFTER_FIRST_ESTIMATE: !nextProps.noUserInput,
AFTER_SIMULATION_COMPLETED:
!nextProps.currentQuestion && nextProps.conversationStarted
!nextProps.nextSteps.length && nextProps.conversationStarted
}
return {
visible: conditions[currentState.askFeedbackTime] && !feedbackAlreadyAsked
@ -58,7 +61,10 @@ export default class Sondage extends Component {
}
render() {
let { satisfaction, showForm, visible, askFeedbackTime } = this.state,
{ language, colours: {colour} } = this.props
{
language,
colours: { colour }
} = this.props
return (
<>
@ -78,7 +84,9 @@ export default class Sondage extends Component {
transitionLeaveTimeout={300}>
{visible && (
<div className="sondage__container">
<div className="sondage" style={{color: colour, borderColor: colour}}>
<div
className="sondage"
style={{ color: colour, borderColor: colour }}>
<span className="sondage__text">
<Trans>Votre avis nous intéresse !</Trans>
</span>