-
- Destinataire
- :
-
-
- ) : null
+ ) : null
+ }
}
-}
+)
diff --git a/source/components/rule/Examples.js b/source/components/rule/Examples.js
index 2b573318c..ab07ef5e7 100644
--- a/source/components/rule/Examples.js
+++ b/source/components/rule/Examples.js
@@ -1,58 +1,59 @@
-import React, { Component } from 'react'
-import { Trans, translate } from 'react-i18next'
-import { compose } from 'ramda'
-import classNames from 'classnames'
-import { connect } from 'react-redux'
-import './Examples.css'
import { setExample } from 'Actions/actions'
+import classNames from 'classnames'
+import { compose } from 'ramda'
+import React, { Component } from 'react'
+import { Trans, withI18n } from 'react-i18next'
+import { connect } from 'react-redux'
import { capitalise0 } from '../../utils'
+import './Examples.css'
-@connect(
- state => ({
- parsedRules: state.parsedRules,
- themeColours: state.themeColours
- }),
- dispatch => ({
- setExample: compose(
- dispatch,
- setExample
- )
- })
-)
-@translate()
-export default class Examples extends Component {
- render() {
- let {
- situationExists,
- rule,
- themeColours,
- setExample,
- currentExample
- } = this.props,
- { examples } = rule
+export default compose(
+ connect(
+ state => ({
+ parsedRules: state.parsedRules,
+ themeColours: state.themeColours
+ }),
+ dispatch => ({
+ setExample: compose(
+ dispatch,
+ setExample
+ )
+ })
+ ),
+ withI18n()
+)(
+ class Examples extends Component {
+ render() {
+ let {
+ situationExists,
+ rule,
+ themeColours,
+ setExample,
+ currentExample
+ } = this.props,
+ { examples } = rule
- if (!examples) return null
- return (
-
-
- Exemples{' '}
-
-
- Cliquez sur un exemple pour le tester
-
-
-
-
- {examples.map(ex => (
-
- ))}
-
+ if (!examples) return null
+ return (
+
+
+ Exemples{' '}
+
+
+ Cliquez sur un exemple pour le tester
+
+
+
+
+ {examples.map(ex => (
+
+ ))}
+
- {situationExists &&
- currentExample && (
+ {situationExists && currentExample && (
)}
-
- )
+
+ )
+ }
}
-}
+)
let Example = ({
ex: { nom, situation },
diff --git a/source/components/rule/References.js b/source/components/rule/References.js
index 83a3e4f8d..79695e445 100644
--- a/source/components/rule/References.js
+++ b/source/components/rule/References.js
@@ -1,77 +1,80 @@
import { groupBy, toPairs } from 'ramda'
import React from 'react'
-import { Trans, translate } from 'react-i18next'
+import { Trans, withI18n } from 'react-i18next'
import references from 'Règles/ressources/références/références.yaml'
import { capitalise0 } from '../../utils'
import './References.css'
-@translate()
-export default class References extends React.Component {
- state = {
- showComplementary: false
- }
- render() {
- let { refs } = this.props,
- { complementary, official = [] } = groupBy(
- ([, link]) => (this.findRefKey(link) ? 'official' : 'complementary')
- )(toPairs(refs)),
- showComplementary = this.state.showComplementary,
- showComplementaryButton = !this.state.showComplementary && complementary
+export default withI18n()(
+ class References extends React.Component {
+ state = {
+ showComplementary: false
+ }
+ render() {
+ let { refs } = this.props,
+ { complementary, official = [] } = groupBy(([, link]) =>
+ this.findRefKey(link) ? 'official' : 'complementary'
+ )(toPairs(refs)),
+ showComplementary = this.state.showComplementary,
+ showComplementaryButton = !this.state.showComplementary && complementary
- return (
-
- )
- }
- renderRef = ([name, link]) => {
- let refKey = this.findRefKey(link),
- refData = (refKey && references[refKey]) || {},
- domain = this.cleanDomain(link)
+ return (
+
+ )
+ }
+ renderRef = ([name, link]) => {
+ let refKey = this.findRefKey(link),
+ refData = (refKey && references[refKey]) || {},
+ domain = this.cleanDomain(link)
- return (
-
-
- {refData.image && (
-
- )}
-
-
- {capitalise0(name)}
-
- {domain}
-
- )
+ return (
+
+
+ {refData.image && (
+
+ )}
+
+
+ {capitalise0(name)}
+
+ {domain}
+
+ )
+ }
+ findRefKey(link) {
+ return Object.keys(references).find(r => link.indexOf(r) > -1)
+ }
+ cleanDomain(link) {
+ return (link.indexOf('://') > -1
+ ? link.split('/')[2]
+ : link.split('/')[0]
+ ).replace('www.', '')
+ }
}
- findRefKey(link) {
- return Object.keys(references).find(r => link.indexOf(r) > -1)
- }
- cleanDomain(link) {
- return (link.indexOf('://') > -1
- ? link.split('/')[2]
- : link.split('/')[0]
- ).replace('www.', '')
- }
-}
+)
diff --git a/source/components/rule/Rule.js b/source/components/rule/Rule.js
index bd405c3fa..577da0bbe 100644
--- a/source/components/rule/Rule.js
+++ b/source/components/rule/Rule.js
@@ -7,10 +7,10 @@ import {
findRuleByDottedName,
findRuleByNamespace
} from 'Engine/rules'
-import { isEmpty } from 'ramda'
+import { compose, isEmpty } from 'ramda'
import React, { Component } from 'react'
import Helmet from 'react-helmet'
-import { Trans, translate } from 'react-i18next'
+import { Trans, withI18n } from 'react-i18next'
import { connect } from 'react-redux'
import { Link } from 'react-router-dom'
import { reduxForm } from 'redux-form'
@@ -26,112 +26,115 @@ import RuleHeader from './Header'
import References from './References'
import './Rule.css'
-@connect((state, props) => ({
- currentExample: state.currentExample,
- flatRules: flatRulesSelector(state),
- valuesToShow: !noUserInputSelector(state),
- analysedRule: ruleAnalysisSelector(state, props),
- analysedExample: exampleAnalysisSelector(state, props)
-}))
-@translate()
-@withLanguage
-class Rule extends Component {
- render() {
- let {
- dottedName,
- currentExample,
- flatRules,
- valuesToShow,
- analysedExample,
- analysedRule,
- language
- } = this.props,
- flatRule = findRuleByDottedName(flatRules, dottedName)
+export default compose(
+ connect((state, props) => ({
+ currentExample: state.currentExample,
+ flatRules: flatRulesSelector(state),
+ valuesToShow: !noUserInputSelector(state),
+ analysedRule: ruleAnalysisSelector(state, props),
+ analysedExample: exampleAnalysisSelector(state, props)
+ })),
+ withI18n(),
+ withLanguage
+)(
+ class Rule extends Component {
+ render() {
+ let {
+ dottedName,
+ currentExample,
+ flatRules,
+ valuesToShow,
+ analysedExample,
+ analysedRule,
+ language
+ } = this.props,
+ flatRule = findRuleByDottedName(flatRules, dottedName)
- let { type, name, title, description, question, ns, icon } = flatRule,
- namespaceRules = findRuleByNamespace(flatRules, dottedName)
+ let { type, name, title, description, question, ns, icon } = flatRule,
+ namespaceRules = findRuleByNamespace(flatRules, dottedName)
- let displayedRule = analysedExample || analysedRule
- let showValues = valuesToShow || currentExample
+ let displayedRule = analysedExample || analysedRule
+ let showValues = valuesToShow || currentExample
- return (
-
-
- {title}
-
-
-
+ return (
+
+
+ {title}
+
+
+
-
- {displayedRule.nodeValue ? (
-
-
{' '}
- {displayedRule.format === 'euros' || displayedRule.formule
- ? Intl.NumberFormat(language, {
- style: 'currency',
- currency: 'EUR'
- }).format(displayedRule.nodeValue)
- : typeof displayedRule.nodeValue !== 'object'
+
+ {displayedRule.nodeValue ? (
+
+ {' '}
+ {displayedRule.format === 'euros' || displayedRule.formule
+ ? Intl.NumberFormat(language, {
+ style: 'currency',
+ currency: 'EUR'
+ }).format(displayedRule.nodeValue)
+ : typeof displayedRule.nodeValue !== 'object'
? displayedRule.nodeValue
: null}
-
- ) : null}
+
+ ) : null}
- {displayedRule.defaultValue != null &&
- typeof displayedRule.defaultValue !== 'object' ? (
-
- Valeur par défaut : {displayedRule.defaultValue}
-
- ) : null}
+ {displayedRule.defaultValue != null &&
+ typeof displayedRule.defaultValue !== 'object' ? (
+
+ Valeur par défaut : {displayedRule.defaultValue}
+
+ ) : null}
- {//flatRule.question &&
- // Fonctionnalité intéressante, à implémenter correctement
- false && }
- {flatRule.ns && (
-
- )}
- {flatRule.note && (
-
- Note:
- {createMarkdownDiv(flatRule.note)}
-
- )}
-
- {!isEmpty(namespaceRules) && (
-
- )}
- {this.renderReferences(flatRule)}
-
-
- )
+ {//flatRule.question &&
+ // Fonctionnalité intéressante, à implémenter correctement
+ false &&
}
+ {flatRule.ns && (
+
+ )}
+ {flatRule.note && (
+
+ Note:
+ {createMarkdownDiv(flatRule.note)}
+
+ )}
+
+ {!isEmpty(namespaceRules) && (
+
+ )}
+ {this.renderReferences(flatRule)}
+
+
+ )
+ }
+
+ renderReferences = ({ références: refs }) =>
+ refs ? (
+
+
+ Références
+
+
+
+ ) : null
}
-
- renderReferences = ({ références: refs }) =>
- refs ? (
-
-
- Références
-
-
-
- ) : null
-}
+)
let NamespaceRulesList = withColours(({ namespaceRules, colours }) => (
@@ -155,15 +158,14 @@ let NamespaceRulesList = withColours(({ namespaceRules, colours }) => (
))
-@reduxForm({
+const UserInput = reduxForm({
form: 'conversation',
destroyOnUnmount: false
-})
-class UserInput extends Component {
- render() {
- let { flatRules, dottedName } = this.props
- return getInputComponent(flatRules)(dottedName)
+})(
+ class UserInput extends Component {
+ render() {
+ let { flatRules, dottedName } = this.props
+ return getInputComponent(flatRules)(dottedName)
+ }
}
-}
-
-export default Rule
+)
diff --git a/source/components/rule/RuleValueVignette.js b/source/components/rule/RuleValueVignette.js
index c5932cad0..8248c10a9 100644
--- a/source/components/rule/RuleValueVignette.js
+++ b/source/components/rule/RuleValueVignette.js
@@ -16,15 +16,15 @@ let RuleValueVignette = ({ name, title, nodeValue: ruleValue }) => (
)
-@withLanguage
-export class RuleValue extends Component {
- render() {
- let { value, language } = this.props
- let unsatisfied = value == null,
- irrelevant = value == 0
- let [className, text] = irrelevant
- ? ['irrelevant', '0']
- : unsatisfied
+export const RuleValue = withLanguage(
+ class RuleValue extends Component {
+ render() {
+ let { value, language } = this.props
+ let unsatisfied = value == null,
+ irrelevant = value == 0
+ let [className, text] = irrelevant
+ ? ['irrelevant', '0']
+ : unsatisfied
? ['unsatisfied', '']
: [
'figure',
@@ -35,18 +35,19 @@ export class RuleValue extends Component {
minimumFractionDigits: 0
}).format(value)
]
- return (
-
-
- {' '}
- {text}
-
-
- )
+ return (
+
+
+ {' '}
+ {text}
+
+
+ )
+ }
}
-}
+)
export default RuleValueVignette
diff --git a/source/components/utils/TrackPageView.js b/source/components/utils/TrackPageView.js
index 4ac622a9d..433027192 100644
--- a/source/components/utils/TrackPageView.js
+++ b/source/components/utils/TrackPageView.js
@@ -1,12 +1,13 @@
import withTracker from 'Components/utils/withTracker'
import { Component } from 'react'
-@withTracker
-export default class TrackPageView extends Component {
- componentDidMount() {
- this.props.tracker.push(['trackPageView'])
+export default withTracker(
+ class TrackPageView extends Component {
+ componentDidMount() {
+ this.props.tracker.push(['trackPageView'])
+ }
+ render() {
+ return null
+ }
}
- render() {
- return null
- }
-}
+)
diff --git a/source/components/utils/withLanguage.js b/source/components/utils/withLanguage.js
index c61b95c12..805c27b9b 100644
--- a/source/components/utils/withLanguage.js
+++ b/source/components/utils/withLanguage.js
@@ -1,20 +1,19 @@
-import PropTypes from 'prop-types'
import React, { Component } from 'react'
+import { withI18n } from 'react-i18next'
export default function withLanguage(WrappedComponent) {
- return class WithLanguage extends Component {
- static contextTypes = {
- i18n: PropTypes.object.isRequired
+ return withI18n()(
+ class WithLanguage extends Component {
+ static displayName = `withLanguage(${Component.displayName ||
+ Component.name})`
+ render() {
+ return (
+
+ )
+ }
}
- static displayName = `withLanguage(${Component.displayName ||
- Component.name})`
- render() {
- return (
-
- )
- }
- }
+ )
}
diff --git a/source/engine/mecanismViews/common.js b/source/engine/mecanismViews/common.js
index 19e13ade7..920c668ee 100644
--- a/source/engine/mecanismViews/common.js
+++ b/source/engine/mecanismViews/common.js
@@ -15,8 +15,8 @@ let treatValue = (data, language) =>
data == null
? '?'
: typeof data == 'boolean'
- ? { true: '✅', false: '✘' }[data]
- : formatNumber(data, language)
+ ? { true: '✅', false: '✘' }[data]
+ : formatNumber(data, language)
export let formatNumber = (data, language) =>
!isNaN(data)
@@ -80,28 +80,29 @@ export function InlineMecanism({ name }) {
}
// Un élément du graphe de calcul qui a une valeur interprétée (à afficher)
-@connect(state => ({ flatRules: flatRulesSelector(state) }))
-export class Leaf extends Component {
- render() {
- let { classes, dottedName, name, value, flatRules, filter } = this.props,
- rule = findRuleByDottedName(flatRules, dottedName)
+export const Leaf = connect(state => ({ flatRules: flatRulesSelector(state) }))(
+ class Leaf extends Component {
+ render() {
+ let { classes, dottedName, name, value, flatRules, filter } = this.props,
+ rule = findRuleByDottedName(flatRules, dottedName)
- return (
-
- {dottedName && (
-
-
-
- {rule.title || capitalise0(name)} {filter}
-
-
-
-
- )}
-
- )
+ return (
+
+ {dottedName && (
+
+
+
+ {rule.title || capitalise0(name)} {filter}
+
+
+
+
+ )}
+
+ )
+ }
}
-}
+)
export function SimpleRuleLink({ rule: { dottedName, title, name } }) {
return (
diff --git a/source/i18n.js b/source/i18n.js
index 2c9261bb0..052332a91 100644
--- a/source/i18n.js
+++ b/source/i18n.js
@@ -21,7 +21,6 @@ let lang =
setToSessionStorage('lang', lang)
i18next.init(
{
- debug: true,
lng: lang,
resources: {
en: {
diff --git a/source/locales/en.yaml b/source/locales/en.yaml
index b59ef4d02..7818e9ec6 100644
--- a/source/locales/en.yaml
+++ b/source/locales/en.yaml
@@ -522,3 +522,11 @@ privacyContent: >
2>
<3>You can opt out below.3>
Vie privée: Privacy
+
+Nom: Name
+Activité principale: Main activity
+Adresse: Address
+Ville: City
+Région: Region
+Nombre d'employés: Number of employees
+Date de création: Creation date
diff --git a/source/sites/embauche.gouv.fr/pages/Couleur.js b/source/sites/embauche.gouv.fr/pages/Couleur.js
index f2232e01a..01a65d669 100644
--- a/source/sites/embauche.gouv.fr/pages/Couleur.js
+++ b/source/sites/embauche.gouv.fr/pages/Couleur.js
@@ -3,32 +3,33 @@ import { SliderPicker } from 'react-color'
import { connect } from 'react-redux'
import Home from './Home'
-@connect(
+export default connect(
state => ({ couleur: state.themeColours.colour }),
dispatch => ({
changeColour: colour => dispatch({ type: 'CHANGE_THEME_COLOUR', colour })
})
-)
-export default class Couleur extends React.Component {
- changeColour = ({ hex }) => this.props.changeColour(hex)
- render() {
- return (
-
-
- Visualisez sur cette page l’apparence du module pour différentes
- couleurs principales.
-
-
-
- La couleur sélectionnée, à déclarer comme attribut
- "data-couleur" du script sur votre page est :{' '}
- {this.props.couleur}
-
-
-
- )
+)(
+ class Couleur extends React.Component {
+ changeColour = ({ hex }) => this.props.changeColour(hex)
+ render() {
+ return (
+
+
+ Visualisez sur cette page l’apparence du module pour différentes
+ couleurs principales.
+
+
+
+ La couleur sélectionnée, à déclarer comme attribut
+ "data-couleur" du script sur votre page est :{' '}
+ {this.props.couleur}
+
+
+
+ )
+ }
}
-}
+)
diff --git a/source/sites/embauche.gouv.fr/pages/ExampleSituations.js b/source/sites/embauche.gouv.fr/pages/ExampleSituations.js
index 5e4b6fd08..ed76cb527 100644
--- a/source/sites/embauche.gouv.fr/pages/ExampleSituations.js
+++ b/source/sites/embauche.gouv.fr/pages/ExampleSituations.js
@@ -1,17 +1,18 @@
// Page listing the engine's currently implemented mecanisms and their tests
-import React, { Component } from 'react'
-import './ExampleSituations.css'
-import examples from 'Règles/cas-types.yaml'
-import { analyseMany } from 'Engine/traverse'
-import { connect } from 'react-redux'
-import {
- ruleDefaultsSelector,
- parsedRulesSelector
-} from 'Selectors/analyseSelectors'
import withColours from 'Components/utils/withColours'
+import { analyseMany } from 'Engine/traverse'
+import { compose } from 'ramda'
+import React, { Component } from 'react'
import emoji from 'react-easy-emoji'
+import { connect } from 'react-redux'
+import examples from 'Règles/cas-types.yaml'
+import {
+ parsedRulesSelector,
+ ruleDefaultsSelector
+} from 'Selectors/analyseSelectors'
+import './ExampleSituations.css'
-class ExampleSituations extends Component {
+export default class ExampleSituations extends Component {
render() {
return (
@@ -28,69 +29,71 @@ class ExampleSituations extends Component {
)
}
}
-@connect(state => ({
- defaults: ruleDefaultsSelector(state),
- parsedRules: parsedRulesSelector(state)
-}))
-@withColours
-class Example extends Component {
- render() {
- let {
- ex: { nom, situation },
- parsedRules,
- defaults,
- colours
- } = this.props,
- [total, net, netAprèsImpôts] = analyseMany(parsedRules, [
- 'total',
- 'net',
- 'net après impôt'
- ])(dottedName => ({ ...defaults, ...situation }[dottedName])).targets,
- figures = [
- total,
- do {
- let dottedName = 'contrat salarié . salaire . brut de base'
- ;({
- dottedName,
- nodeValue: situation[dottedName],
- title: 'Salaire brut'
- })
- },
- net,
- { ...netAprèsImpôts, title: 'Après impôt' }
- ]
- return (
-
- {nom}
-
- {figures.map(t => (
- -
-
{t.title}
+const Example = compose(
+ connect(state => ({
+ defaults: ruleDefaultsSelector(state),
+ parsedRules: parsedRulesSelector(state)
+ })),
+ withColours
+)(
+ class Example extends Component {
+ render() {
+ let {
+ ex: { nom, situation },
+ parsedRules,
+ defaults,
+ colours
+ } = this.props,
+ [total, net, netAprèsImpôts] = analyseMany(parsedRules, [
+ 'total',
+ 'net',
+ 'net après impôt'
+ ])(dottedName => ({ ...defaults, ...situation }[dottedName])).targets,
+ figures = [
+ total,
+ do {
+ let dottedName = 'contrat salarié . salaire . brut de base'
+ ;({
+ dottedName,
+ nodeValue: situation[dottedName],
+ title: 'Salaire brut'
+ })
+ },
+ net,
+ { ...netAprèsImpôts, title: 'Après impôt' }
+ ]
+
+ return (
+ -
+
{nom}
+
+ {figures.map(t => (
+ -
+
{t.title}
+
+ {Math.round(t.nodeValue)} €
+
+
+ ))}{' '}
+ -
+
Prélèvements
- {Math.round(t.nodeValue)} €
+ {do {
+ let de = figures[0].nodeValue,
+ à = figures[3].nodeValue
+ Math.round(((de - à) / de) * 100)
+ }}{' '}
+ %
- ))}{' '}
- -
-
Prélèvements
-
- {do {
- let de = figures[0].nodeValue,
- à = figures[3].nodeValue
- Math.round(((de - à) / de) * 100)
- }}{' '}
- %
-
-
-
-
- )
+
+
+ )
+ }
}
-}
-
-export default ExampleSituations
+)
diff --git a/source/sites/embauche.gouv.fr/pages/Header.js b/source/sites/embauche.gouv.fr/pages/Header.js
index 5fd0c6746..b94932f55 100644
--- a/source/sites/embauche.gouv.fr/pages/Header.js
+++ b/source/sites/embauche.gouv.fr/pages/Header.js
@@ -1,58 +1,60 @@
import LangSwitcher from 'Components/LangSwitcher'
import React, { Component } from 'react'
-import { translate } from 'react-i18next'
-import { connect } from 'react-redux'
import { withRouter } from 'react-router'
import { Link } from 'react-router-dom'
+import { withI18n } from 'react-i18next'
import Logo from '../images/logo/logo-simulateur.svg'
import './Header.css'
+import { compose } from 'ramda';
-@withRouter
-@translate()
-export class Header extends Component {
- state = {
- mobileNavVisible: false
- }
- togglemobileNavVisible = () =>
- this.setState({ mobileNavVisible: !this.state.mobileNavVisible })
+export const Header = compose(
+ withRouter,
+ withI18n()
+)(
+ class Header extends Component {
+ state = {
+ mobileNavVisible: false
+ }
+ togglemobileNavVisible = () =>
+ this.setState({ mobileNavVisible: !this.state.mobileNavVisible })
- render() {
- return (
-