@@ -6,72 +6,91 @@ import checkIcon from "./assets/images/checkIcon.svg";
66import questionIcon from "./assets/images/questionIcon.svg" ;
77import xIcon from "./assets/images/xIcon.svg" ;
88
9- export default function EligibilityResults ( { results } : { results : Accessor < ResultDetail [ ] | undefined > } ) {
9+
10+ export default function EligibilityResults (
11+ { results } : { results : Accessor < ResultDetail [ ] | undefined > }
12+ ) {
1013 console . log ( results ( ) ) ;
1114 return (
1215 < div class = "my-2 mx-12" >
1316 < h2 class = "text-gray-600 font-bold" > Eligibility Results</ h2 >
1417 < For each = { results ( ) ?? [ ] } >
15- { ( benefit ) => (
16- < div class = "border-gray-500 border p-5 my-4 rounded-lg shadow-md" >
17- < Switch >
18- < Match when = { benefit . result === true } >
19- < p class = "mb-3 bg-green-200 w-fit py-1 px-6 rounded-full font-bold text-gray-800 text-sm" >
20- Eligible
21- </ p >
22- </ Match >
23- < Match when = { benefit . result === null } >
24- < p class = "mb-3 bg-yellow-200 w-fit py-1 px-6 rounded-full font-bold text-gray-800 text-sm" >
25- Need more information
26- </ p >
27- </ Match >
28- < Match when = { benefit . result === false } >
29- < p class = "mb-3 bg-red-200 w-fit py-1 px-6 rounded-full font-bold text-gray-800 text-sm" >
30- Ineligible
31- </ p >
32- </ Match >
33- </ Switch >
34- < h3 class = "font-bold mb-2 text-lg" > { benefit . displayName } </ h3 >
35- < div class = "my-2" >
36- < For each = { benefit . checks ?? [ ] } >
37- { ( check ) => (
38- < p class = "mb-1" >
39- < Switch >
40- < Match when = { check . result === true } >
41- < img src = { checkIcon } alt = "" class = "inline w-4 mr-2" />
42- </ Match >
43- < Match when = { check . result === null } >
44- < img
45- src = { questionIcon }
46- alt = ""
47- class = "inline w-4 mr-2"
48- />
49- </ Match >
50- < Match when = { check . result === false } >
51- < img src = { xIcon } alt = "" class = "inline w-4 mr-2" />
52- </ Match >
53- </ Switch >
54- < span class = "text-xs" > { check . displayName } </ span >
55- </ p >
56- ) }
57- </ For >
58- </ div >
59- { benefit . info && (
60- < >
61- < h4 class = "font-bold mb-1 text-sm" > Overview</ h4 >
62- < p class = "mb-4 text-xs" > { benefit . info } </ p >
63- </ >
64- ) }
65- { benefit . appLink && (
66- < a href = { benefit . appLink } target = "_blank" >
67- < p class = "bg-green-600 px-5 py-2 rounded-lg font-bold text-white w-fit text-sm" >
68- Apply Now
69- </ p >
70- </ a >
71- ) }
72- </ div >
73- ) }
18+ { ( benefit ) => < BenefitResult benefit = { benefit } /> }
7419 </ For >
7520 </ div >
7621 ) ;
7722}
23+
24+ function BenefitResult ( { benefit } : { benefit : ResultDetail } ) {
25+ const isApplicationLinkEnabled : boolean = benefit . result ;
26+ const applicationLinkCls : string = (
27+ isApplicationLinkEnabled ? "" : "pointer-events-none opacity-50"
28+ ) ;
29+
30+ return (
31+ < div class = "border-gray-500 border p-5 my-4 rounded-lg shadow-md" >
32+ < Switch >
33+ < Match when = { benefit . result === true } >
34+ < p class = "mb-3 bg-green-200 w-fit py-1 px-6 rounded-full font-bold text-gray-800 text-sm" >
35+ Eligible
36+ </ p >
37+ </ Match >
38+ < Match when = { benefit . result === null } >
39+ < p class = "mb-3 bg-yellow-200 w-fit py-1 px-6 rounded-full font-bold text-gray-800 text-sm" >
40+ Need more information
41+ </ p >
42+ </ Match >
43+ < Match when = { benefit . result === false } >
44+ < p class = "mb-3 bg-red-200 w-fit py-1 px-6 rounded-full font-bold text-gray-800 text-sm" >
45+ Ineligible
46+ </ p >
47+ </ Match >
48+ </ Switch >
49+ < div class = "[&:has(+div)]:mb-2" >
50+ < h3 class = "font-bold text-lg" > { benefit . displayName } </ h3 >
51+ < For each = { benefit . checks ?? [ ] } >
52+ { ( check ) => (
53+ < p class = "mb-1" >
54+ < Switch >
55+ < Match when = { check . result === true } >
56+ < img src = { checkIcon } alt = "" class = "inline w-4 mr-2" />
57+ </ Match >
58+ < Match when = { check . result === null } >
59+ < img
60+ src = { questionIcon }
61+ alt = ""
62+ class = "inline w-4 mr-2"
63+ />
64+ </ Match >
65+ < Match when = { check . result === false } >
66+ < img src = { xIcon } alt = "" class = "inline w-4 mr-2" />
67+ </ Match >
68+ </ Switch >
69+ < span class = "text-xs" > { check . displayName } </ span >
70+ </ p >
71+ ) }
72+ </ For >
73+ </ div >
74+ { benefit . info && (
75+ < div class = "[&:has(+div)]:mb-4" >
76+ < h4 class = "font-bold mb-1 text-sm" > Overview</ h4 >
77+ < p class = "text-xs" > { benefit . info } </ p >
78+ </ div >
79+ ) }
80+ { benefit . appLink && (
81+ < div class = "[&:has(+div)]:mb-4" >
82+ < a href = { benefit . appLink } target = "_blank" class = { applicationLinkCls } >
83+ < p
84+ class = "
85+ px-5 py-2 rounded-lg select-none
86+ rounded-lg font-bold text-white w-fit text-sm
87+ bg-green-600 hover:bg-green-700 transition-colors"
88+ >
89+ Apply Now
90+ </ p >
91+ </ a >
92+ </ div >
93+ ) }
94+ </ div >
95+ ) ;
96+ }
0 commit comments