mon-entreprise/source/components/ProgressTip.js

54 lines
1.3 KiB
JavaScript
Raw Normal View History

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