Skip to content

Commit ff21879

Browse files
committed
add tags to eligibility overview
1 parent 7d4c1c1 commit ff21879

4 files changed

Lines changed: 98 additions & 36 deletions

File tree

src/core/utils/buildEligibilityReports.js

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@ export const buildEligibilityReports = (validationReport, metadata, hydrationDat
77
};
88
}
99

10-
console.log("Validation Report:", validationReport);
11-
console.log("Metadata:", metadata);
12-
13-
const reports = validationReport['ff:hasEvaluatedRequirementProfile'] || [];
10+
const reports = validationReport['ff:hasEvaluatedRequirementProfile'] || [];
1411
const allReports = reports.map(report => {
15-
const rpUri = report['ff:hasRpUri']?.['@id'] || null;
12+
const rpUri = report['ff:hasRpUri']?.['@id'] || null;
1613
const result = report['ff:hasEligibilityStatus']?.['@id'] || null;
1714

1815
// hydration data
@@ -30,9 +27,35 @@ export const buildEligibilityReports = (validationReport, metadata, hydrationDat
3027
// metadata
3128
const rpMetadata = metadata['ff:hasRP']?.find(rp => rp['@id'] === rpUri)
3229
const validationStage = rpMetadata?.['ff:validationStage']?.['@id'] || 'Unknown Validation Stage';
30+
const associatedLaw = rpMetadata?.['ff:legalBasis'];
31+
const providingAgency = rpMetadata?.['ff:providingAgency']?.['@id'];
32+
const administrativeLevel = rpMetadata?.['ff:administrativeLevel']?.['@id'];
3333

34-
return { uri: rpUri, result, id, title, category, description, status, requiredDocuments, additionalSupport, legalBasis, furtherInformation, validationStage };
35-
});
34+
const rawCategories = rpMetadata?.['ff:category'];
35+
const categoriesArray = rawCategories
36+
? (Array.isArray(rawCategories) ? rawCategories : [rawCategories])
37+
: [];
38+
const benefitCategories = categoriesArray.map(cat => cat['@id']).filter(Boolean);
39+
40+
return {
41+
uri: rpUri,
42+
result,
43+
id,
44+
title,
45+
category,
46+
description,
47+
status,
48+
requiredDocuments,
49+
additionalSupport,
50+
legalBasis,
51+
furtherInformation,
52+
validationStage,
53+
associatedLaw,
54+
providingAgency,
55+
administrativeLevel,
56+
benefitCategories
57+
};
58+
});
3659

3760
const eligibilityStatus = allReports.reduce((acc, report) => {
3861
const { category, result } = report;
@@ -52,7 +75,7 @@ export const buildEligibilityReports = (validationReport, metadata, hydrationDat
5275

5376
if (report.validationStage === "ff:preliminary-validation") {
5477
acc[category][result].preliminary.push(report);
55-
}
78+
}
5679
} else {
5780
if (!acc[category][result]) {
5881
acc[category][result] = [];

src/ui/screens/eligibilty-overview/EligibilityOverviewScreenContainer.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ const EligibilityOverviewScreenContainer = () => {
1616
const metadata = useMetadataStore((state) => state.metadata);
1717
const eligibilityData = useEligibilityData(validationReport, metadata, hydrationData, language);
1818

19+
console.log("eligibilityData", eligibilityData);
20+
1921
const iconPaths = useMemo(() => ({
2022
eligible: `${process.env.PUBLIC_URL}/assets/images/application/icon-image-eligible.svg`,
2123
preliminaryEligible: `${process.env.PUBLIC_URL}/assets/images/application/icon-image-preliminary-eligible.svg`,

src/ui/screens/eligibilty-overview/components/EligibilityOverviewItem.js

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@ import { HBox, VBox } from '@/ui/shared-components/LayoutBoxes';
44
import theme from '@/theme';
55
import RegularButton from '@/ui/shared-components/buttons/RegularButton';
66
import { useSelectedBenefitStore, useSelectedTopicsStore } from "@/ui/storage/zustand";
7+
import EligibilityOverTag from './EligibilityOverviewTag';
78

89
const EligibilityOverviewItem = ({ item, eligible }) => {
910
const color = eligible === 'indeterminate' ? 'black.light' : 'black.main';
1011
const setSelectedBenefit = useSelectedBenefitStore((state) => state.setSelectedBenefit);
1112
const clearSelectedTopics = useSelectedTopicsStore((state) => state.clear);
1213

14+
console.log('item', item);
15+
1316
return (
1417
<VBox
1518
sx={{
@@ -73,35 +76,30 @@ const EligibilityOverviewItem = ({ item, eligible }) => {
7376
}}
7477
>
7578
<HBox sx={{ justifyContent: 'flex-end', flexWrap: 'wrap', gap: 1 }}>
76-
<HBox sx={{
77-
border: `1px solid ${theme.palette.green.main}`,
78-
padding: '6px 10px',
79-
borderRadius: theme.shape.borderRadius,
80-
}}>
81-
<Typography variant='body2' sx={{}}>
82-
Bundesleistung
83-
</Typography>
84-
</HBox>
85-
<HBox sx={{
86-
border: `1px solid ${theme.palette.pink.main}`,
87-
padding: '6px 10px',
88-
borderRadius: theme.shape.borderRadius,
89-
}}>
90-
<Typography variant='body2' sx={{}}>
91-
Agentur für Arbeit
92-
</Typography>
93-
</HBox>
94-
<HBox sx={{
95-
border: `1px solid ${theme.palette.blue.main}`,
96-
padding: '6px 10px',
97-
borderRadius: theme.shape.borderRadius,
98-
}}>
99-
<Typography variant='body2' sx={{}}>
100-
Rehaibilitierung und Teilhabe
101-
</Typography>
102-
</HBox>
79+
{
80+
item.administrativeLevel && (
81+
<EligibilityOverTag tag={item.administrativeLevel} tagType={'administrativeLevel'} />
82+
)
83+
}
84+
{
85+
item.associatedLaw && (
86+
<EligibilityOverTag tag={item.associatedLaw} tagType={'associatedLaw'} />
87+
)
88+
}
89+
{
90+
item.providingAgency && (
91+
<EligibilityOverTag tag={item.providingAgency} tagType={'providingAgency'} />
92+
)
93+
}
94+
{
95+
item.benefitCategories.length > 0 && (
96+
item.benefitCategories.map((category, index) => (
97+
<EligibilityOverTag key={index} tag={category} tagType={'benefitCategory'} />
98+
))
99+
)
100+
}
103101
</HBox>
104-
<HBox sx={{ gap: 2, flexWrap: 'wrap' }}>
102+
<HBox sx={{ gap: 2, flexWrap: 'wrap', justifyContent: 'flex-end' }}>
105103
<RegularButton
106104
variant={'blueHollow'}
107105
text={'app.browseAll.learnMoreBtn'}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import React from 'react';
2+
import { Typography } from '@mui/material';
3+
import { HBox } from '@/ui/shared-components/LayoutBoxes';
4+
import theme from '@/theme';
5+
6+
const EligibilityOverTag = ({ tag, tagType }) => {
7+
8+
let tagStyle;
9+
switch (tagType) {
10+
case 'administrativeLevel':
11+
tagStyle = theme.palette.green.main ;
12+
break;
13+
case 'associatedLaw':
14+
tagStyle = theme.palette.pink.main;
15+
break;
16+
case 'providingAgency':
17+
tagStyle = theme.palette.blue.main ;
18+
break;
19+
case 'benefitCategory':
20+
tagStyle = theme.palette.blue.main;
21+
break;
22+
default:
23+
tagStyle = theme.palette.black.main;
24+
}
25+
26+
return (
27+
<HBox sx={{
28+
border: `1px solid ${tagStyle}`,
29+
padding: '6px 10px',
30+
borderRadius: theme.shape.borderRadius,
31+
}}>
32+
<Typography variant='body2' sx={{}}>
33+
{tag}
34+
</Typography>
35+
</HBox>
36+
);
37+
}
38+
39+
export default EligibilityOverTag;

0 commit comments

Comments
 (0)