diff --git a/source/components/publicodesUtils.js b/source/components/publicodesUtils.js index 299df812a0..47a4c8e9b9 100644 --- a/source/components/publicodesUtils.js +++ b/source/components/publicodesUtils.js @@ -1,4 +1,10 @@ +import { capitalise0 } from '../utils' + export const parentName = (dottedName, outputSeparator = ' . ') => splitName(dottedName).slice(0, -1).join(outputSeparator) export const splitName = (dottedName) => dottedName.split(' . ') + +export const title = (rule) => + rule.titre || + capitalise0(splitName(rule.dottedName)[splitName(rule.dottedName).length - 1]) diff --git a/source/sites/publicodes/ActionPlus.js b/source/sites/publicodes/ActionPlus.js index 32e273a4e3..9fd61632d8 100644 --- a/source/sites/publicodes/ActionPlus.js +++ b/source/sites/publicodes/ActionPlus.js @@ -15,9 +15,16 @@ export default () => { return (
+
+ + + +
diff --git a/source/sites/publicodes/ListeActionPlus.js b/source/sites/publicodes/ListeActionPlus.js index 3c8e85e2cb..5c482441bc 100644 --- a/source/sites/publicodes/ListeActionPlus.js +++ b/source/sites/publicodes/ListeActionPlus.js @@ -3,10 +3,12 @@ import { ScrollToTop } from 'Components/utils/Scroll' import { utils } from 'publicodes' import { useContext } from 'react' import emoji from 'react-easy-emoji' +import { useSelector } from 'react-redux' import { Link } from 'react-router-dom' +import { title } from '../../components/publicodesUtils' export default () => { - const rules = useContext(EngineContext).getParsedRules() + const rules = useSelector((state) => state.rules) const plusListe = Object.entries(rules) .map(([dottedName, rule]) => ({ ...rule, dottedName })) .filter((r) => r.plus) @@ -19,9 +21,7 @@ export default () => {

- - Découvrez les enjeux qui se cachent derrière chaque action. - + Découvrez les enjeux qui se cachent derrière chaque action.

    { } `} > - {plusListe.map(({ dottedName, icons, title }) => ( -
  • - + {plusListe.map((rule) => ( +
  • +
    { } `} > -
    {emoji(icons || '🎯')}
    -
    {title}
    +
    {emoji(rule.icônes || '🎯')}
    +
    {title(rule)}