mon-entreprise/source/components/ProgressTip.js

61 lines
1.6 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 => ({
done: state.done,
foldedSteps: state.foldedSteps,
nextSteps: state.nextSteps,
colour: state.themeColours.colour
}))
@translate()
export default class ProgressTip extends Component {
state = {
nbFoldedStepsForFirstEstimation: null
}
componentWillReceiveProps(newProps) {
if (newProps.done && this.state.nbFoldedStepsForFirstEstimation == null)
this.setState({
nbFoldedStepsForFirstEstimation: newProps.foldedSteps.length
})
}
render() {
let { done, nextSteps, foldedSteps, colour } = this.props,
2017-12-20 15:21:29 +00:00
nbQuestions = nextSteps.length
if (!done) return null
return (
<div className="tip">
2017-12-20 15:21:29 +00:00
{nbQuestions != 0 &&
this.state.nbFoldedStepsForFirstEstimation === foldedSteps.length && (
2018-03-27 11:38:02 +00:00
<p><Trans i18nKey="first">Votre première estimation est disponible !</Trans></p>
)}
2017-12-20 15:21:29 +00:00
{nbQuestions != 0 && (
<p>
2017-12-20 15:21:29 +00:00
{nbQuestions === 1
2018-03-27 11:38:02 +00:00
?
<Trans i18nKey="lastQ">Une dernière question !</Trans>
:
<Trans i18nKey="questionsLeft" count={nbQuestions}>
Il reste moins de {{nbQuestions}} questions.
</Trans>
}
<Line
percent={
100 * foldedSteps.length / (foldedSteps.length + nbQuestions)
}
strokeWidth="1"
strokeColor={colour}
trailColor="white"
strokeLinecap="butt"
/>
</p>
)}
</div>
)
}
}