Les suggestions apparaissent peut importe la période
parent
2374879234
commit
6dd3122f3b
|
@ -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>
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue