Simplification des calculs de la vignette de résultat
parent
99702f1b54
commit
156bbda400
|
@ -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>
|
||||
|
|
|
@ -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) => {
|
||||
|
|
Loading…
Reference in New Issue