Skip to content

Commit 7496732

Browse files
committed
fix localised content
1 parent cf74090 commit 7496732

4 files changed

Lines changed: 33 additions & 161 deletions

File tree

src/ui/screens/benefit-page/BenefitPageScreen.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,20 @@ const BenefitPageScreen = ({
1515
isDesktop,
1616
benefitPageData,
1717
localisedData,
18+
xml,
1819
validatedStatus,
1920
categoryTitles,
2021
matchingGraph
2122
}) => {
22-
23+
2324
return (
2425
<Layout isApp={true} logo={false} back="Back">
2526
<AppScreenWrapperContainer backTarget={'/eligibility-overview'}>
2627
<VBox sx={{ gap: { xs: 4, md: 8 } }}>
2728
<BenefitPageHeader id={id} benefit={benefitPageData} validatedStatus={validatedStatus} categoryTitles={categoryTitles} />
2829
<VBox sx={{ gap: { xs: 4, md: 8 } }}>
2930
<BenefitPageGeneral t={t} isDesktop={isDesktop} benefitPageData={benefitPageData} />
30-
<BenefitPageApplication t={t} isDesktop={isDesktop} benefitPageData={benefitPageData} />
31+
<BenefitPageApplication t={t} isDesktop={isDesktop} benefitPageData={benefitPageData} xml={xml} />
3132
{
3233
localisedData && (
3334
<BenefitPageLocal t={t} isDesktop={isDesktop} localisedData={localisedData} />

src/ui/screens/benefit-page/BenefitPageScreenContainer.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { useLanguageStore } from '@/ui/storage/useLanguageStore';
99
import matchingEngineManager from "@/core/managers/matchingEngineManager";
1010
import { useUserStore } from '@/ui/storage/zustand';
1111
import { useStore } from "@/ui/shared-components/ViewportUpdater";
12+
import { useFetchLocaliseData } from './hooks/useFetchLocalisedData';
13+
import useFetchData from '@/ui/shared-hooks/utility/useFetchResource';
1214

1315
const BenefitPageScreenContainer = () => {
1416
const { id } = useParams();
@@ -21,6 +23,8 @@ const BenefitPageScreenContainer = () => {
2123
const categoryTitles = useBuildCategoryTitles(id, language);
2224
const validatedStatus = useValidatedStatus(id);
2325
const activeUserId = useUserStore((state) => state.activeUserId);
26+
const localisedData = useFetchLocaliseData(benefitPageData);
27+
const xml = useFetchData(`assets/data/xml/${id.split(":")[1]}.xml`);
2428

2529
useEffect(() => {
2630
const fetchMatchingReport = async () => {
@@ -42,6 +46,8 @@ const BenefitPageScreenContainer = () => {
4246
id={id}
4347
isDesktop={isDesktop}
4448
benefitPageData={benefitPageData}
49+
localisedData={localisedData}
50+
xml={xml}
4551
validatedStatus={validatedStatus}
4652
categoryTitles={categoryTitles}
4753
matchingGraph={matchingGraph}

src/ui/screens/benefit-page/components/BenefitPageApplication.js

Lines changed: 2 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -9,151 +9,12 @@ import RegularButton from '@/ui/shared-components/buttons/RegularButton';
99
const BenefitPageApplication = ({
1010
t,
1111
isDesktop,
12-
benefitPageData
12+
benefitPageData,
13+
xml
1314
}) => {
1415
const [open, setOpen] = useState(false);
1516
const objectIcon = `${process.env.PUBLIC_URL}/assets/images/benefit-pages/airplane.svg`;
1617

17-
const xml = `
18-
<?xml version="1.0" encoding="UTF-8"?>
19-
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:color="http://www.omg.org/spec/BPMN/non-normative/color/1.0" id="Defs_gruendungsbonus_plus_lane_even" targetNamespace="https://example.org/bpmn#" exporter="bpmn-js (https://demo.bpmn.io)" exporterVersion="18.6.1">
20-
<bpmn:process id="p_gruendungsbonus_plus" isExecutable="false">
21-
<bpmn:laneSet id="ls_gbplus">
22-
<bpmn:lane id="lane_user" name="Antragsteller:in">
23-
<bpmn:flowNodeRef>s</bpmn:flowNodeRef>
24-
<bpmn:flowNodeRef>t0</bpmn:flowNodeRef>
25-
<bpmn:flowNodeRef>e_no</bpmn:flowNodeRef>
26-
<bpmn:flowNodeRef>t6</bpmn:flowNodeRef>
27-
</bpmn:lane>
28-
<bpmn:lane id="lane_ibb_bt" name="IBB Business Team">
29-
<bpmn:flowNodeRef>t2</bpmn:flowNodeRef>
30-
<bpmn:flowNodeRef>t4</bpmn:flowNodeRef>
31-
<bpmn:flowNodeRef>g</bpmn:flowNodeRef>
32-
<bpmn:flowNodeRef>e_ok</bpmn:flowNodeRef>
33-
</bpmn:lane>
34-
</bpmn:laneSet>
35-
<bpmn:startEvent id="s" name="Start">
36-
<bpmn:outgoing>f0</bpmn:outgoing>
37-
</bpmn:startEvent>
38-
<bpmn:manualTask id="t0" name="Online-Antrag einreichen">
39-
<bpmn:incoming>f0</bpmn:incoming>
40-
<bpmn:outgoing>f1</bpmn:outgoing>
41-
</bpmn:manualTask>
42-
<bpmn:userTask id="t2" name="Formale &#38; inhaltliche Prüfung">
43-
<bpmn:incoming>f1</bpmn:incoming>
44-
<bpmn:outgoing>f2</bpmn:outgoing>
45-
</bpmn:userTask>
46-
<bpmn:exclusiveGateway id="g" name="Bewilligt?">
47-
<bpmn:incoming>f2</bpmn:incoming>
48-
<bpmn:outgoing>fy</bpmn:outgoing>
49-
<bpmn:outgoing>fn</bpmn:outgoing>
50-
</bpmn:exclusiveGateway>
51-
<bpmn:sendTask id="t4" name="Zuwendungsbescheid &#38; Auszahlung in Tranchen (Erstattungsprinzip)">
52-
<bpmn:incoming>fy</bpmn:incoming>
53-
<bpmn:outgoing>f3</bpmn:outgoing>
54-
</bpmn:sendTask>
55-
<bpmn:manualTask id="t6" name="Widerspruch/Nachbesserung möglich">
56-
<bpmn:incoming>fn</bpmn:incoming>
57-
<bpmn:outgoing>f4</bpmn:outgoing>
58-
</bpmn:manualTask>
59-
<bpmn:endEvent id="e_ok" name="Bewilligt">
60-
<bpmn:incoming>f3</bpmn:incoming>
61-
</bpmn:endEvent>
62-
<bpmn:endEvent id="e_no" name="Abgelehnt">
63-
<bpmn:incoming>f4</bpmn:incoming>
64-
</bpmn:endEvent>
65-
<bpmn:sequenceFlow id="f0" sourceRef="s" targetRef="t0" />
66-
<bpmn:sequenceFlow id="f1" sourceRef="t0" targetRef="t2" />
67-
<bpmn:sequenceFlow id="f2" sourceRef="t2" targetRef="g" />
68-
<bpmn:sequenceFlow id="fy" name="ja" sourceRef="g" targetRef="t4" />
69-
<bpmn:sequenceFlow id="fn" name="nein" sourceRef="g" targetRef="t6" />
70-
<bpmn:sequenceFlow id="f3" sourceRef="t4" targetRef="e_ok" />
71-
<bpmn:sequenceFlow id="f4" sourceRef="t6" targetRef="e_no" />
72-
</bpmn:process>
73-
<bpmndi:BPMNDiagram id="D_gruendungsbonus_plus">
74-
<bpmndi:BPMNPlane id="P_gruendungsbonus_plus" bpmnElement="p_gruendungsbonus_plus">
75-
<bpmndi:BPMNShape id="L_ibb_bt" bpmnElement="lane_ibb_bt" isHorizontal="true" color:background-color="#F5F8FF" color:border-color="#A3A3A3">
76-
<dc:Bounds x="150" y="200" width="1320" height="160" />
77-
</bpmndi:BPMNShape>
78-
<bpmndi:BPMNShape id="L_user" bpmnElement="lane_user" isHorizontal="true" color:background-color="#F6FFF6" color:border-color="#A3A3A3">
79-
<dc:Bounds x="150" y="80" width="1320" height="120" />
80-
</bpmndi:BPMNShape>
81-
<bpmndi:BPMNShape id="Ds" bpmnElement="s" color:background-color="#F0FFF4" color:border-color="#047857">
82-
<dc:Bounds x="200" y="122" width="36" height="36" />
83-
</bpmndi:BPMNShape>
84-
<bpmndi:BPMNShape id="Dt0" bpmnElement="t0" color:background-color="#E8F7E8" color:border-color="#2E7D32">
85-
<dc:Bounds x="260" y="110" width="240" height="60" />
86-
</bpmndi:BPMNShape>
87-
<bpmndi:BPMNShape id="Dt2" bpmnElement="t2" color:background-color="#EAF0FF" color:border-color="#1E40AF">
88-
<dc:Bounds x="620" y="245" width="260" height="70" />
89-
</bpmndi:BPMNShape>
90-
<bpmndi:BPMNShape id="Dt4" bpmnElement="t4" color:background-color="#EAF0FF" color:border-color="#1E40AF">
91-
<dc:Bounds x="1040" y="245" width="320" height="70" />
92-
</bpmndi:BPMNShape>
93-
<bpmndi:BPMNShape id="Dg" bpmnElement="g" isMarkerVisible="true" color:background-color="#F5F5F5" color:border-color="#6B7280">
94-
<dc:Bounds x="935" y="255" width="50" height="50" />
95-
<bpmndi:BPMNLabel>
96-
<dc:Bounds x="937" y="305" width="47" height="14" />
97-
</bpmndi:BPMNLabel>
98-
</bpmndi:BPMNShape>
99-
<bpmndi:BPMNShape id="De_ok" bpmnElement="e_ok" color:background-color="#ECFDF5" color:border-color="#059669">
100-
<dc:Bounds x="1402" y="262" width="36" height="36" />
101-
<bpmndi:BPMNLabel>
102-
<dc:Bounds x="1400" y="298" width="41" height="14" />
103-
</bpmndi:BPMNLabel>
104-
</bpmndi:BPMNShape>
105-
<bpmndi:BPMNShape id="De_no" bpmnElement="e_no" color:background-color="#FEF2F2" color:border-color="#B91C1C">
106-
<dc:Bounds x="1402" y="122" width="36" height="36" />
107-
<bpmndi:BPMNLabel>
108-
<dc:Bounds x="1395" y="158" width="50" height="14" />
109-
</bpmndi:BPMNLabel>
110-
</bpmndi:BPMNShape>
111-
<bpmndi:BPMNShape id="Dt6" bpmnElement="t6" color:background-color="#E8F7E8" color:border-color="#B45309">
112-
<dc:Bounds x="1070" y="110" width="260" height="60" />
113-
</bpmndi:BPMNShape>
114-
<bpmndi:BPMNEdge id="f0d" bpmnElement="f0">
115-
<di:waypoint x="236" y="140" />
116-
<di:waypoint x="260" y="140" />
117-
</bpmndi:BPMNEdge>
118-
<bpmndi:BPMNEdge id="f1d" bpmnElement="f1">
119-
<di:waypoint x="500" y="140" />
120-
<di:waypoint x="600" y="140" />
121-
<di:waypoint x="600" y="280" />
122-
<di:waypoint x="620" y="280" />
123-
</bpmndi:BPMNEdge>
124-
<bpmndi:BPMNEdge id="f2d" bpmnElement="f2">
125-
<di:waypoint x="880" y="282" />
126-
<di:waypoint x="937" y="282" />
127-
</bpmndi:BPMNEdge>
128-
<bpmndi:BPMNEdge id="fyd" bpmnElement="fy">
129-
<di:waypoint x="982" y="283" />
130-
<di:waypoint x="1040" y="283" />
131-
<bpmndi:BPMNLabel>
132-
<dc:Bounds x="1029" y="262" width="9" height="14" />
133-
</bpmndi:BPMNLabel>
134-
</bpmndi:BPMNEdge>
135-
<bpmndi:BPMNEdge id="fnd" bpmnElement="fn">
136-
<di:waypoint x="960" y="255" />
137-
<di:waypoint x="960" y="140" />
138-
<di:waypoint x="1070" y="140" />
139-
<bpmndi:BPMNLabel>
140-
<dc:Bounds x="965" y="188" width="21" height="14" />
141-
</bpmndi:BPMNLabel>
142-
</bpmndi:BPMNEdge>
143-
<bpmndi:BPMNEdge id="f3d" bpmnElement="f3">
144-
<di:waypoint x="1360" y="280" />
145-
<di:waypoint x="1402" y="280" />
146-
</bpmndi:BPMNEdge>
147-
<bpmndi:BPMNEdge id="f4d" bpmnElement="f4">
148-
<di:waypoint x="1330" y="140" />
149-
<di:waypoint x="1402" y="140" />
150-
</bpmndi:BPMNEdge>
151-
</bpmndi:BPMNPlane>
152-
</bpmndi:BPMNDiagram>
153-
</bpmn:definitions>
154-
155-
`;
156-
15718
return (
15819
<VBox
15920
sx={{

src/ui/screens/benefit-page/hooks/useFetchLocalisedData.js

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,28 @@ import { useLanguageStore } from "@/ui/storage/useLanguageStore";
44
import { useUserStore } from "@/ui/storage/zustand";
55
import userManager from "@/core/managers/userManager";
66

7-
export const useFetchLocaliseData = ({benefitPageData}) => {
7+
export const useFetchLocaliseData = (benefitPageData) => {
88
const language = useLanguageStore(s => s.language);
99
const activeUserId = useUserStore(s => s.activeUserId);
10-
const loc = userManager.retrieveUserField(activeUserId, "ff:hasResidence");
11-
10+
1211
return useMemo(() => {
13-
const list = benefitPageData?.localisedData ?? [];
14-
if (!list.length) return null;
15-
16-
const byLoc = Object.fromEntries(
17-
list.map(item => [item?.pattern?.["ff:hasResidence"], item])
18-
);
19-
20-
const match =
21-
byLoc[loc] ??
22-
byLoc["ff:hasResidence-other"] ??
23-
list[0];
24-
25-
return match ? pickLang(match, language, null) : null;
26-
}, [benefitPageData, loc, language]);
27-
};
12+
if (!activeUserId) return null;
13+
14+
const loc = userManager.retrieveUserField(activeUserId, "ff:hasResidence");
15+
if (!loc) return null ;
16+
17+
const list = benefitPageData?.localisedData ?? [];
18+
if (!list.length) return null;
19+
20+
const byLoc = Object.fromEntries(
21+
list.map(item => [item?.pattern?.["ff:hasResidence"], item])
22+
);
23+
24+
const match =
25+
byLoc[loc] ??
26+
byLoc["ff:hasResidence-other"] ??
27+
list[0];
28+
29+
return match ? pickLang(match, language, null) : null;
30+
}, [activeUserId, benefitPageData, language]);
31+
};

0 commit comments

Comments
 (0)