Simplification des calculs de la vignette de résultat

pull/77/head
mama 2017-10-03 14:35:18 +02:00
parent 99702f1b54
commit 156bbda400
2 changed files with 11 additions and 20 deletions

View File

@ -11,20 +11,14 @@ import './RuleValueVignette.css'
export default ({
name,
type,
"non applicable si": nonApplicable,
formule: { nodeValue: formuleValue },
conversationStarted
conversationStarted,
nodeValue: ruleValue
}) =>
do {
//TODO quel bordel, à revoir
let ruleValue = computeRuleValue(
formuleValue,
nonApplicable && nonApplicable.nodeValue
),
let
unsatisfied = ruleValue == null,
nonApplicableValue = nonApplicable ? nonApplicable.nodeValue : false,
irrelevant = nonApplicableValue === true || formuleValue == 0,
number = nonApplicableValue == false && formuleValue != null
irrelevant = ruleValue == 0,
number = typeof ruleValue == 'number' && ruleValue > 0
;<span
key={name}
@ -45,7 +39,7 @@ export default ({
: unsatisfied
? "En attente de vos réponses..."
: <span className="figure">
{humanFigure(2)(formuleValue) + "€"}
{humanFigure(2)(ruleValue) + "€"}
</span>)}
</p>
</div>

View File

@ -328,20 +328,17 @@ let treat = (rules, rule) => rawNode => {
let parsedNode = onNodeType(rawNode)
return parsedNode.evaluate ? parsedNode :
{...parsedNode, evaluate: defaultEvaluate}
{...parsedNode, evaluate: defaultEvaluate}
}
//TODO c'est moche :
export let computeRuleValue = (formuleValue, condValue) =>
condValue === undefined
? formuleValue
: formuleValue === 0
? 0
: condValue === null
? null
: condValue === true
? formuleValue
: formuleValue === 0
? 0
: formuleValue
: condValue === null ? null : condValue === true ? 0 : formuleValue
export let treatRuleRoot = (rules, rule) => {
let evaluate = (situationGate, parsedRules, r) => {