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