Explication graphique de l'allegement

pull/171/head
Mael 2018-02-21 13:46:38 +01:00
parent 2b97218c69
commit 0197f9647b
2 changed files with 62 additions and 1 deletions

View File

@ -0,0 +1,60 @@
import React from 'react'
import { Node } from './common'
import { makeJsx } from '../evaluation'
import { mapObjIndexed, values } from 'ramda'
export default (nodeValue, explanation) => (
<div>
<Node
classes="mecanism allègement"
name="allègement"
value={nodeValue}
child={
<ul className="properties">
<li key="assiette">
<span className="key">assiette: </span>
<span className="value">{makeJsx(explanation.assiette)}</span>
</li>
{explanation.franchise && (
<li key="franchise">
<span className="key">franchise: </span>
<span className="value">{makeJsx(explanation.franchise)}</span>
</li>
)}
{explanation.décote && (
<li key="décote">
<span className="key">décote: </span>
<span className="value">
<ObjectView data={explanation.décote} />
</span>
</li>
)}
{explanation.abattement && (
<li key="abattement">
<span className="key">abattement: </span>
<span className="value">{makeJsx(explanation.abattement)}</span>
</li>
)}
</ul>
}
/>
</div>
)
let ObjectView = ({ data }) =>
console.log('data', data) || (
<ul className="properties">
{values(
mapObjIndexed(
(v, k) => (
<li key={k}>
{' '}
<span className="key">{k}: </span>
<span className="value">{makeJsx(v)}</span>
</li>
),
data
)
)}
</ul>
)

View File

@ -50,6 +50,7 @@ import {
import 'react-virtualized/styles.css'
import Somme from './mecanismViews/Somme'
import Allègement from './mecanismViews/Allègement'
import buildSelectionView from './mecanismViews/Selection'
import uniroot from './uniroot'
@ -575,7 +576,7 @@ export let mecanismReduction = (recurse, k, v) => {
return {
evaluate,
jsx: (nodeValue, explanation) => <div>Allègement</div>,
jsx: Allègement,
explanation,
category: 'mecanism',
name: 'allègement',