2017-12-05 11:58:24 +00:00
|
|
|
import React, { Component } from 'react'
|
2018-03-29 07:58:20 +00:00
|
|
|
import { Trans, translate } from 'react-i18next'
|
2017-12-20 15:21:29 +00:00
|
|
|
import { connect } from 'react-redux'
|
|
|
|
import { withRouter } from 'react-router'
|
2017-12-05 11:58:24 +00:00
|
|
|
import './ProgressTip.css'
|
2018-01-24 11:00:15 +00:00
|
|
|
import { Line } from 'rc-progress'
|
2017-12-05 11:58:24 +00:00
|
|
|
|
|
|
|
@withRouter
|
|
|
|
@connect(state => ({
|
|
|
|
foldedSteps: state.foldedSteps,
|
2018-01-10 16:51:35 +00:00
|
|
|
nextSteps: state.nextSteps,
|
2018-01-24 11:00:15 +00:00
|
|
|
colour: state.themeColours.colour
|
2017-12-05 11:58:24 +00:00
|
|
|
}))
|
2018-03-29 07:58:20 +00:00
|
|
|
@translate()
|
2017-12-05 11:58:24 +00:00
|
|
|
export default class ProgressTip extends Component {
|
|
|
|
render() {
|
2018-03-12 09:38:29 +00:00
|
|
|
let {
|
|
|
|
done,
|
|
|
|
nextSteps,
|
|
|
|
foldedSteps,
|
|
|
|
colour,
|
|
|
|
conversationVisible,
|
|
|
|
selectingTargets
|
|
|
|
} = this.props,
|
2017-12-20 15:21:29 +00:00
|
|
|
nbQuestions = nextSteps.length
|
2018-03-12 09:38:29 +00:00
|
|
|
|
|
|
|
if (selectingTargets && !conversationVisible)
|
2018-03-12 16:36:34 +00:00
|
|
|
return nbQuestions ? (
|
|
|
|
<p>Vous aurez {nextSteps.length} questions !</p>
|
|
|
|
) : null
|
2018-03-12 09:38:29 +00:00
|
|
|
if (!conversationVisible) return null
|
2017-12-05 11:58:24 +00:00
|
|
|
return (
|
2018-03-14 16:10:28 +00:00
|
|
|
nbQuestions != 0 && (
|
|
|
|
<div className="progressTip">
|
|
|
|
{foldedSteps.length > 0 && (
|
2018-01-24 11:00:15 +00:00
|
|
|
<Line
|
|
|
|
percent={
|
|
|
|
100 * foldedSteps.length / (foldedSteps.length + nbQuestions)
|
|
|
|
}
|
|
|
|
strokeWidth="1"
|
|
|
|
strokeColor={colour}
|
|
|
|
strokeLinecap="butt"
|
2017-12-05 11:58:24 +00:00
|
|
|
/>
|
2018-03-14 16:10:28 +00:00
|
|
|
)}
|
|
|
|
<p>
|
|
|
|
{nbQuestions === 1
|
|
|
|
? 'Une dernière question !'
|
|
|
|
: `Moins de ${nbQuestions} questions`}
|
2017-12-05 11:58:24 +00:00
|
|
|
</p>
|
2018-03-14 16:10:28 +00:00
|
|
|
</div>
|
|
|
|
)
|
2017-12-05 11:58:24 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|