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'
|
2018-03-29 17:26:35 +00:00
|
|
|
import { pick } from 'ramda'
|
2017-12-05 11:58:24 +00:00
|
|
|
|
|
|
|
@withRouter
|
2018-03-29 07:58:20 +00:00
|
|
|
@translate()
|
2018-03-29 17:26:35 +00:00
|
|
|
@connect(
|
|
|
|
pick(['foldedSteps', 'nextSteps', 'themeColours', 'conversationStarted'])
|
|
|
|
)
|
2017-12-05 11:58:24 +00:00
|
|
|
export default class ProgressTip extends Component {
|
|
|
|
render() {
|
2018-03-12 09:38:29 +00:00
|
|
|
let {
|
|
|
|
nextSteps,
|
|
|
|
foldedSteps,
|
2018-04-05 17:19:53 +00:00
|
|
|
themeColours: { colour, textColourOnWhite },
|
2018-03-29 17:26:35 +00:00
|
|
|
conversationStarted
|
2018-03-12 09:38:29 +00:00
|
|
|
} = this.props,
|
2017-12-20 15:21:29 +00:00
|
|
|
nbQuestions = nextSteps.length
|
2018-03-12 09:38:29 +00:00
|
|
|
|
2018-03-29 17:26:35 +00:00
|
|
|
if (!conversationStarted) return null
|
2017-12-05 11:58:24 +00:00
|
|
|
return (
|
2018-03-14 16:10:28 +00:00
|
|
|
nbQuestions != 0 && (
|
|
|
|
<div className="progressTip">
|
2018-04-05 17:01:54 +00:00
|
|
|
<Line
|
|
|
|
style={{
|
|
|
|
visibility: foldedSteps.length > 0 ? 'visible' : 'hidden'
|
|
|
|
}}
|
|
|
|
percent={
|
|
|
|
100 * foldedSteps.length / (foldedSteps.length + nbQuestions)
|
|
|
|
}
|
|
|
|
trailWidth="1"
|
|
|
|
strokeWidth="2"
|
|
|
|
strokeColor={colour}
|
|
|
|
/>
|
|
|
|
|
2018-04-05 17:19:53 +00:00
|
|
|
<p style={{ color: textColourOnWhite }}>
|
|
|
|
{nbQuestions === 1 ? (
|
|
|
|
'dernière question !'
|
|
|
|
) : (
|
|
|
|
<span>
|
|
|
|
<i className="fa fa-minus-square-o" aria-hidden="true" />
|
|
|
|
{` de ${nbQuestions} questions`}
|
|
|
|
</span>
|
|
|
|
)}
|
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
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|