|
1 | 1 | import React, { useEffect, useState, useRef } from 'react'; |
2 | 2 | import theme from '@/theme'; |
3 | | -import { VBox } from '@/ui/shared-components/LayoutBoxes'; |
| 3 | +import { HBox, VBox } from '@/ui/shared-components/LayoutBoxes'; |
| 4 | +import AntSwitch from "@/ui/shared-components/AntSwitch"; |
4 | 5 | import { Typography } from "@mui/material"; |
5 | 6 | import mermaid from "mermaid"; |
6 | 7 | import { graphToMermaid } from "@foerderfunke/matching-engine/src/rule-graph/EvalGraph"; |
7 | 8 | import matchingEngineManager from "@/core/managers/matchingEngineManager"; |
| 9 | +import useTranslation from "@/ui/language/useTranslation"; |
8 | 10 |
|
9 | 11 | function enablePanZoom(svg) { |
10 | 12 | if (!svg) return () => { }; |
@@ -69,9 +71,10 @@ mermaid.initialize({ |
69 | 71 |
|
70 | 72 |
|
71 | 73 | export default function FlowChart({ evalGraph }) { |
| 74 | + const { t } = useTranslation(); |
72 | 75 |
|
73 | 76 | const [svgContent, setSvgContent] = useState(""); |
74 | | - const graphTypeEval = true; |
| 77 | + const [graphTypeEval, setGraphTypeEval] = useState(false); |
75 | 78 | const printLabels = true; |
76 | 79 | const orientationVertical = false; |
77 | 80 |
|
@@ -123,7 +126,7 @@ export default function FlowChart({ evalGraph }) { |
123 | 126 | if (!evalGraph) return; |
124 | 127 | const me = matchingEngineManager.matchingEngineInstance; |
125 | 128 | const mermaidDef = graphToMermaid( |
126 | | - graphTypeEval ? evalGraph.ruleGraph : evalGraph, |
| 129 | + graphTypeEval ? evalGraph : evalGraph.ruleGraph, |
127 | 130 | me, printLabels, orientationVertical |
128 | 131 | ); |
129 | 132 |
|
@@ -161,6 +164,11 @@ export default function FlowChart({ evalGraph }) { |
161 | 164 |
|
162 | 165 | return ( |
163 | 166 | <div style={{ position: "relative" }}> |
| 167 | + <HBox gap={1} alignItems="center" style={{ paddingBottom: "10px" }}> |
| 168 | + <span>{t("app.benefitPage.requirements.toggleRule")}</span> |
| 169 | + <AntSwitch checked={graphTypeEval} onChange={(e) => setGraphTypeEval(e.target.checked)} color="white"/> |
| 170 | + <span>{t("app.benefitPage.requirements.toggleEval")}</span> |
| 171 | + </HBox> |
164 | 172 | <VBox |
165 | 173 | sx={{ |
166 | 174 | backgroundColor: 'greyTransparent.main', |
|
0 commit comments