From ef0fcf6e053410d429c71abe0a4c322e5ff4bbc2 Mon Sep 17 00:00:00 2001 From: Mael Date: Mon, 4 Mar 2024 17:36:18 +0100 Subject: [PATCH 01/17] =?UTF-8?q?Premi=C3=A8re=20impl=C3=A9mentation=20des?= =?UTF-8?q?=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/personas/Tests.tsx | 68 +++++++++ app/personas/TestsUI.tsx | 13 ++ app/personas/page.tsx | 2 + "app/r\303\250gles/.~lock.tests.csv#" | 1 + "app/r\303\250gles/tests.csv" | 193 ++++++++++++++++++++++++++ 5 files changed, 277 insertions(+) create mode 100644 app/personas/Tests.tsx create mode 100644 app/personas/TestsUI.tsx create mode 100644 "app/r\303\250gles/.~lock.tests.csv#" create mode 100644 "app/r\303\250gles/tests.csv" diff --git a/app/personas/Tests.tsx b/app/personas/Tests.tsx new file mode 100644 index 00000000..a7d51970 --- /dev/null +++ b/app/personas/Tests.tsx @@ -0,0 +1,68 @@ +import { Section } from '@/components/UI' +import rawTests from '@/app/règles/tests.csv' +import { GreenCell, Table } from './TestsUI' +import rules from '@/app/règles/rules' +import Publicodes from 'publicodes' +import { formatValue } from '@/node_modules/publicodes/dist/index' + +const tests = rawTests.filter( + (test) => test['aide complémentaire MAR'] === 'oui', +) + +const engine = new Publicodes(rules) + +export default function Tests() { + return ( +
+

Tests

+

+ Pour assurer la fiabilité de notre modèle de calcul, voici une liste de + tests effectués via un modèle tiers. +

+ + + + + + + + + + + + {tests.map((test) => { + const evaluation = engine + .setSituation({ + travaux: test['montant de travaux HT'], + sauts: test['saut de classe'], + 'ménage . revenu . classe': `"${ + { + TMO: 'très modeste', + MO: 'modeste', + INT: 'intermédiaire', + SUP: 'supérieure', + }[test['ressource ménage']] + }"`, + }) + .evaluate('MPR . accompagnée') + + const value = formatValue(evaluation) + + const expectedValue = test['aide MPR'] + const valid = + Math.round(evaluation.nodeValue) === Math.round(+expectedValue) + return ( + + + + + + {valid ? {value} : } + + ) + })} + +
Classe de revenuSauts DPETravaux HTAide MPR-A testAide MPR-A recalculée
{test['ressource ménage']}{test['saut de classe']}{test['montant de travaux HT']} €{expectedValue} €{value}
+
+ ) +} diff --git a/app/personas/TestsUI.tsx b/app/personas/TestsUI.tsx new file mode 100644 index 00000000..b631c536 --- /dev/null +++ b/app/personas/TestsUI.tsx @@ -0,0 +1,13 @@ +'use client' +import styled from 'styled-components' + +export const Table = styled.table` + width: 100%; + td { + text-align: center; + } +` + +export const GreenCell = styled.td` + background: #c4fad5; +` diff --git a/app/personas/page.tsx b/app/personas/page.tsx index 2146b69b..e6874554 100644 --- a/app/personas/page.tsx +++ b/app/personas/page.tsx @@ -1,11 +1,13 @@ import Footer from '@/components/Footer' import { Suspense } from 'react' import Personas from '../Personas' +import Tests from './Tests' export default function PersonasPage() { return ( +