Les suggestions apparaissent peut importe la période

pull/543/head
Johan Girod 2019-05-17 17:45:55 +02:00
parent 2374879234
commit 6dd3122f3b
No known key found for this signature in database
GPG Key ID: 9E27B57DA2E8AE12
1 changed files with 28 additions and 22 deletions

View File

@ -2,9 +2,9 @@ import withColours from 'Components/utils/withColours'
import { compose, toPairs } from 'ramda'
import React, { Component } from 'react'
import { withTranslation } from 'react-i18next'
import './InputSuggestions.css'
import { connect } from 'react-redux'
import { formValueSelector } from 'redux-form'
import './InputSuggestions.css'
export default compose(
withColours,
@ -28,31 +28,37 @@ export default compose(
} = this.props
if (!suggestions) return null
//TODO all suggestions are defined for a monthly simulation
if (rulePeriod === 'flexible' && period !== 'mois') return null
return (
<div className="inputSuggestions">
suggestions:
<ul>
{toPairs(suggestions).map(([text, value]) => (
<li
key={value}
onClick={() => {
onFirstClick(value)
if (this.state.suggestion !== value)
this.setState({ suggestion: value })
else onSecondClick && onSecondClick(value)
}}
style={{
color: colouredBackground
? colours.textColour
: colours.textColourOnWhite
}}>
<span title={t('cliquez pour insérer cette suggestion')}>
{text}
</span>
</li>
))}
{toPairs(suggestions).map(([text, value]) => {
// TODO : ce serait mieux de déplacer cette logique dans le moteur
const adjustedValue =
rulePeriod === 'flexible' && period === 'année'
? value * 12
: value
return (
<li
key={value}
onClick={() => {
onFirstClick(adjustedValue)
if (this.state.suggestion !== adjustedValue)
this.setState({ suggestion: adjustedValue })
else onSecondClick && onSecondClick(adjustedValue)
}}
style={{
color: colouredBackground
? colours.textColour
: colours.textColourOnWhite
}}>
<span title={t('cliquez pour insérer cette suggestion')}>
{text}
</span>
</li>
)
})}
</ul>
</div>
)