Skip to content

Commit ab64050

Browse files
committed
add eligibility banner to benefit page
1 parent 431ad0e commit ab64050

6 files changed

Lines changed: 63 additions & 30 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const BenefitPageScreen = ({
1717
localisedData,
1818
xml,
1919
validatedStatus,
20+
validationResult,
2021
categoryTitles,
2122
matchingGraph
2223
}) => {
@@ -25,7 +26,7 @@ const BenefitPageScreen = ({
2526
<Layout isApp={true} logo={false} back="Back">
2627
<AppScreenWrapperContainer backTarget={'/eligibility-overview'}>
2728
<VBox sx={{ gap: { xs: 4, md: 8 } }}>
28-
<BenefitPageHeader id={id} benefit={benefitPageData} validatedStatus={validatedStatus} categoryTitles={categoryTitles} />
29+
<BenefitPageHeader id={id} benefit={benefitPageData} validatedStatus={validatedStatus} validationResult={validationResult} categoryTitles={categoryTitles} />
2930
<VBox sx={{ gap: { xs: 4, md: 8 }}}>
3031
<BenefitPageGeneral t={t} isDesktop={isDesktop} benefitPageData={benefitPageData} />
3132
<BenefitPageApplication t={t} isDesktop={isDesktop} benefitPageData={benefitPageData} xml={xml} />

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const BenefitPageScreenContainer = () => {
2121

2222
const benefitPageData = useFetchStaticBenefitPageData(id, language);
2323
const categoryTitles = useBuildCategoryTitles(id, language);
24-
const validatedStatus = useValidatedStatus(id);
24+
const {validatedStatus, validationResult} = useValidatedStatus(id);
2525
const activeUserId = useUserStore((state) => state.activeUserId);
2626
const localisedData = useFetchLocaliseData(benefitPageData);
2727
const xml = useFetchData(`assets/data/xml/${id.split(":")[1]}.xml`);
@@ -49,6 +49,7 @@ const BenefitPageScreenContainer = () => {
4949
localisedData={localisedData}
5050
xml={xml}
5151
validatedStatus={validatedStatus}
52+
validationResult={validationResult}
5253
categoryTitles={categoryTitles}
5354
matchingGraph={matchingGraph}
5455
/>

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

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,63 @@ import { HBox, VBox } from "@/ui/shared-components/LayoutBoxes";
66
import { useSelectedBenefitsStore, useSelectedTopicsStore } from "@/ui/storage/zustand";
77
import useTranslation from "@/ui/language/useTranslation";
88
import theme from "@/theme";
9+
import EligibilityOverviewBanner from "../../eligibilty-overview/components/EligibilityOverviewBanner";
910

10-
const BenefitPageHeader = ({ id, benefit, validatedStatus, categoryTitles }) => {
11+
const BenefitPageHeader = ({
12+
id,
13+
benefit,
14+
validatedStatus,
15+
validationResult,
16+
categoryTitles
17+
}) => {
1118
const { t } = useTranslation();
1219
const [leiKaInfo, setLeiKaInfo] = useState(false);
1320

1421
const setSelectedBenefits = useSelectedBenefitsStore((state) => state.setSelectedBenefits);
1522
const clearSelectedTopics = useSelectedTopicsStore((state) => state.clear);
1623

1724
return (
18-
<HBox sx={{ justifyContent: 'space-between', gap: 4, flexWrap: 'wrap' }}>
19-
<VBox sx={{ gap: 2 }}>
25+
<HBox sx={{ justifyContent: 'space-between', gap: {xs: 2, md: 4}, flexWrap: 'wrap' }}>
26+
<VBox sx={{ gap: {xs: 2, md: 4} }}>
2027
<Typography variant="h1" sx={{ wordBreak: 'break-word' }}>
2128
{benefit?.title}
2229
</Typography>
2330
<VBox sx={{ gap: 2 }}>
2431
<VBox sx={{ gap: 1 }}>
32+
{
33+
validatedStatus && (
34+
<HBox>
35+
<EligibilityOverviewBanner t={t} eligible={validationResult} />
36+
</HBox>
37+
)
38+
}
2539
<HBox sx={{ gap: 1, alignItems: 'center' }}>
26-
<Typography variant="body2" sx={{ color: 'black.light' }}>
27-
LeiKa-Id: {benefit?.leikaId}
28-
</Typography>
29-
<IconButton
30-
sx={{
31-
width: 24,
32-
height: 24,
33-
borderRadius: theme.shape.circle,
34-
display: 'flex',
35-
alignItems: 'center',
36-
justifyContent: 'center',
37-
backgroundColor: 'white',
38-
'&:hover': {
39-
backgroundColor: 'black.light',
40-
},
41-
}}
42-
onClick={() => setLeiKaInfo(!leiKaInfo)}
43-
>
44-
<InfoOutlinedIcon sx={{ fontSize: 16, color: 'black.light' }} />
45-
</IconButton>
40+
{
41+
benefit?.leikaId && (
42+
<>
43+
<Typography variant="body2" sx={{ color: 'black.light' }}>
44+
LeiKa-Id: {benefit?.leikaId}
45+
</Typography>
46+
<IconButton
47+
sx={{
48+
width: 24,
49+
height: 24,
50+
borderRadius: theme.shape.circle,
51+
display: 'flex',
52+
alignItems: 'center',
53+
justifyContent: 'center',
54+
backgroundColor: 'white',
55+
'&:hover': {
56+
backgroundColor: 'black.light',
57+
},
58+
}}
59+
onClick={() => setLeiKaInfo(!leiKaInfo)}
60+
>
61+
<InfoOutlinedIcon sx={{ fontSize: 16, color: 'black.light' }} />
62+
</IconButton>
63+
</>
64+
)
65+
}
4666
</HBox>
4767
{leiKaInfo && (
4868
<Typography variant="body2" sx={{ color: 'black.light' }}>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const useFetchStaticBenefitPageData = (id, language) => {
2020
const resource = hydrationData[id] || {};
2121
return {
2222
title: pickLang(resource?.title, language, 'Unknown Title'),
23-
leikaId: getField(resource, 'leika_id', 'Unknown Id'),
23+
leikaId: getField(resource, 'leika_id', null),
2424
teaser: pickLang(resource?.teaser, language, null),
2525
brief : pickLang(resource?.general?.brief, language, null),
2626
scope : pickLang(resource?.general?.scope, language, null),

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ const useValidatedStatus = (id) => {
77
return useMemo(() => {
88
if (!validationReport) return false;
99
const report = validationReport?.['ff:hasEvaluatedRequirementProfile']?.find(rp => rp['ff:hasRpUri']['@id'] === id);
10-
return report?.["ff:hasEligibilityStatus"]["@id"] !== "ff:missingData" || false;
10+
return {
11+
validatedStatus: report?.["ff:hasEligibilityStatus"]["@id"] !== "ff:missingData" || false,
12+
validationResult: report?.["ff:hasEligibilityStatus"]["@id"]?.replace(/^ff:/, "") || null
13+
}
1114
}, [id, validationReport]);
1215
};
1316

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ const EligibilityOverviewBanner = ({ t, eligible }) => {
2525
border: '1px solid rgba(255, 0, 0, 0.2)',
2626
backgroundColor: 'error.light'
2727
}
28+
case 'ineligible':
29+
return {
30+
text: 'app.browseAll.item.notEligible',
31+
border: '1px solid rgba(255, 0, 0, 0.2)',
32+
backgroundColor: 'error.light'
33+
}
2834
default:
2935
return {
3036
text: 'app.browseAll.item.missingData',
@@ -36,11 +42,13 @@ const EligibilityOverviewBanner = ({ t, eligible }) => {
3642
const eligibilityIcon = (() => {
3743
switch (eligible) {
3844
case 'eligible':
39-
return <CheckIcon sx={{ fontSize: '16px' }} />;
45+
return <CheckIcon sx={{ fontSize: '20spx' }} />;
4046
case 'non-eligible':
41-
return <ClearIcon sx={{ fontSize: '16px' }} />;
47+
return <ClearIcon sx={{ fontSize: '20px' }} />;
48+
case 'ineligible':
49+
return <ClearIcon sx={{ fontSize: '20px' }} />;
4250
default:
43-
return <ClearIcon sx={{ fontSize: '16px' }} />;
51+
return <ClearIcon sx={{ fontSize: '20px' }} />;
4452
}
4553
})();
4654

0 commit comments

Comments
 (0)