From 79dde7e55580a0d7164b1a3ae9f17bc2910a6497 Mon Sep 17 00:00:00 2001 From: Mael Thomas Date: Tue, 10 Jan 2017 15:39:40 +0100 Subject: [PATCH] =?UTF-8?q?[moteur]=20R=C3=A9cup=C3=A9rer=20le=20type=20de?= =?UTF-8?q?s=20questions,=20=C3=A9bauche=20d'agencement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/components/CDD.css | 30 ++++++++++++++++++++++++++++++ source/components/CDD.js | 38 ++++++++++++++++++++++++++++---------- source/load-cdd-rules.js | 17 ----------------- source/traverse.js | 17 +++++++++++++++-- 4 files changed, 73 insertions(+), 29 deletions(-) create mode 100644 source/components/CDD.css delete mode 100644 source/load-cdd-rules.js diff --git a/source/components/CDD.css b/source/components/CDD.css new file mode 100644 index 000000000..7dce93847 --- /dev/null +++ b/source/components/CDD.css @@ -0,0 +1,30 @@ +#sim { + padding: 2em; +} + + +#sim section { + padding: 2em; +} + +#conversation { + display: flex; + justify-content: space-around; + min-height: 10em; + margin: 3em 0; +} + +#questions-answers { + background: blue; + min-width: 50%; +} + +#help { + background: green; + min-width: 30%; +} + +#results { + width: 100%; + background: purple; +} diff --git a/source/components/CDD.js b/source/components/CDD.js index ea0795dda..63cf3cb03 100644 --- a/source/components/CDD.js +++ b/source/components/CDD.js @@ -1,10 +1,18 @@ import React, { Component } from 'react' -import {analyseSituation} from '../traverse' +import {analyseSituation, variableType} from '../traverse' +import './CDD.css' export default class CDD extends Component { + state = { + situation: {} + } render() { + + let [missingVariable] = analyseSituation(this.state.situation) + let type = variableType(missingVariable) + return ( -
+

Le CDD en France est un contrat d'exception au CDI. On y a donc recours sous certaines conditions seulement. Cet outil vous aidera à respecter ces conditions et à calculer le prix mensuel de l'embauche, qui en dépend, en vous proposant une suite de questions. @@ -15,14 +23,24 @@ export default class CDD extends Component { *: écrivez à contact@contact.contact (on fera mieux après). La loi française est complexe, souvent à raison. Nous ne la changerons pas, mais pouvons la rendre plus transparente.

-
-
    - {analyseSituation().map(v => -
  • - {v} -
  • - )} -
+
+
+
e.preventDefault()}> + + +
+
+
+ Aide +
+
+
+ Résultats
) diff --git a/source/load-cdd-rules.js b/source/load-cdd-rules.js deleted file mode 100644 index d79643e25..000000000 --- a/source/load-cdd-rules.js +++ /dev/null @@ -1,17 +0,0 @@ -import R from 'ramda' - -/* Load yaml files */ - -let context = require.context( - '../règles/rémunération-travail/cdd/simples', true, - /([a-zA-Z]|-|_)+.yaml$/) - - -let rules = R.pipe( - R.map(context), - //flatten - R.unnest, -)(context.keys()) - - -export default rules.filter(r => r != null) diff --git a/source/traverse.js b/source/traverse.js index 83934c4ff..a79c23f03 100644 --- a/source/traverse.js +++ b/source/traverse.js @@ -1,7 +1,8 @@ import removeDiacritics from './utils/remove-diacritics' import R from 'ramda' -import cddRules from './load-cdd-rules' +import rules from './load-rules' import initialSituation from './initialSituation' +import {findRuleByName, extractRuleTypeAndName} from './model' /* @@ -152,12 +153,24 @@ let analyseVariable = situation => }, [[], null]) ) +let selectedRules = rules.filter(r => extractRuleTypeAndName(r)[1] == 'CIF CDD') + export let analyseSituation = (situation = initialSituation) => R.pipe( R.map(analyseVariable(situation)), R.flatten() - )(cddRules) + )(selectedRules) +console.log(rules) + + +export let variableType = name => { + let rule = findRuleByName(name) + // tellement peu de variables pour l'instant + // que c'est très simpliste + if (!rule) return 'boolean' + if (rule.formule['somme']) return 'numeric' +} // console.log('RES', JSON.stringify(res))