import React, { Component } from 'react' // import {findRuleByName} from '../engine/rules.js' import {analyseSituation} from '../engine/traverse' import './Rule.css' import JSONTree from 'react-json-tree' import R from 'ramda' import PageTypeIcon from './PageTypeIcon' import {connect} from 'react-redux' import {formValueSelector} from 'redux-form' // situationGate function useful for testing : let testingSituationGate = v => R.path(v.split('.'))( { "Salariat ":{ " CDD ":{ " événements":"_", " motif":"usage", " engagement employeur complément formation":"non", " durée contrat":"2" }, " contrat aidé":"non", " salaire de base": 1481, " congés non pris": 3 } }) @connect(state => ({ situationGate: name => formValueSelector('conversation')(state, name) })) export default class Rule extends Component { render() { let { params: {name}, situationGate } = this.props, rule = analyseSituation( testingSituationGate ).find(R.propEq('name', name)) if (!rule) { this.props.router.push('/404') return null } return (
Pourquoi cette règle me concerne ? Comment est-elle calculée ?

{rule.type} {name}

{rule.description}

Propriétés

Références

{this.renderReferences(rule)}
{ do { let cond = R.toPairs(rule).find(([,v]) => v.rulePropType == 'cond') cond != null &&

Conditions de déclenchement

}}

Calcul

{/*
						
				
*/}
) } renderReferences(rule) { return ( rule['référence'] &&
{rule['référence']}
) || ( rule['références'] && ) } } let RuleProp = ({nodeValue, explanation, name}) =>
{name}
{ explanation.category == 'mecanism' && } { explanation.category == 'expression' && }
let Mecanism = ({nodeValue, name, explanation}) =>
{name}
{R.contains(name)(["l'une de ces conditions", 'toutes ces conditions']) && } {name == 'multiplication' && } {name == 'le maximum de' && }
let Multiplication = ({base, rate}) =>
× { rate.explanation ? : }
let Variable = ({nodeValue, variableName}) => {variableName} let Percentage = ({percentage}) => {percentage} let Expression = ({nodeValue, expression}) =>
{expression}
let NodeValue = ({data}) => do { console.log('NodeValue', data) let valeur = data == null ? '?' : ( R.is(Number)(data) ? Math.round(data) : ( data ? 'oui' : 'non') ); ←  {valeur} } let Formula = ({explanation, nodeValue}) => do {
{expression}
} let JSONView = ({o, rootKey}) => ''} theme={theme} hideRoot={true} shouldExpandNode={() => true} data={rootKey ? {[rootKey]: o} : o} /> var theme = { scheme: 'atelier forest', author: 'bram de haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/forest)', base00: '#1b1918', base01: '#2c2421', base02: '#68615e', base03: '#766e6b', base04: '#9c9491', base05: '#a8a19f', base06: '#e6e2e0', base07: '#f1efee', base08: '#f22c40', base09: '#df5320', base0A: '#d5911a', base0B: '#5ab738', base0C: '#00ad9c', base0D: '#407ee7', base0E: '#6666ea', base0F: '#c33ff3' }