diff --git a/source/engine/mecanismViews/Variations.js b/source/engine/mecanismViews/Variations.js index e1da11cef..f97b270c6 100644 --- a/source/engine/mecanismViews/Variations.js +++ b/source/engine/mecanismViews/Variations.js @@ -6,52 +6,90 @@ import classNames from 'classnames' import writtenNumbers from '../../locales/writtenNumbers.yaml' import withLanguage from 'Components/utils/withLanguage' import { Trans } from 'react-i18next' +import { ShowValuesConsumer } from 'Components/rule/ShowValuesContext' +import emoji from 'react-easy-emoji' +import { useState } from 'react' let Comp = withLanguage(function Variations({ language, nodeValue, explanation }) { + let [expandedVariation, toggleVariation] = useState(null) + return ( - -

- Cette règle présente{' '} - {writtenNumbers[language][explanation.length]}{' '} - : -

- - - } - /> + + {showValues => ( + +

+ Cette règle présente{' '} + {writtenNumbers[language][explanation.length]}{' '} + : +

+
    + {explanation.map(({ condition, consequence, satisfied }, i) => ( +
  • + {showValues && + (!satisfied && !(expandedVariation === i)) ? ( +

    + non applicable{' '} + +

    + ) : ( + <> + {expandedVariation === i && ( + + )} +
    + {condition && ( + + Si {makeJsx(condition)} + + )} +
    + + {condition ? ( + Alors + ) : ( + Sinon + )}{' '} + : + + + {consequence && makeJsx(consequence)} + +
    +
    + + )} +
  • + ))} +
+ + } + /> + )} +
) }) // eslint-disable-next-line