@@ -23,16 +23,46 @@ const Home = () => {
23
23
const [ open , setOpen ] = useState ( false ) ;
24
24
25
25
const [ step , setStep ] = useState ( 0 ) ;
26
- const totalSteps = 4 ;
26
+ const totalSteps = 3 ;
27
27
28
- useEffect ( ( ) => {
29
- const completedCards = cardCheckList . filter ( ( card ) => card . completed === true ) ;
30
- setStep ( completedCards . length ) ;
31
- } , [ cardCheckList ] ) ;
28
+ const steps = [
29
+ {
30
+ label : 'Introduction AirQo Analytics demo video' ,
31
+ time : '1 min' ,
32
+ link : '#' ,
33
+ func : ( ) => handleModel ( ) ,
34
+ disabled : true ,
35
+ } ,
36
+ {
37
+ label : 'Choose location you most interested in' ,
38
+ time : '2 min' ,
39
+ link : '/analytics' ,
40
+ func : ( ) => handleCardClick ( 1 ) ,
41
+ } ,
42
+ {
43
+ label : 'Complete your AirQo Analytics profile' ,
44
+ time : '4 min' ,
45
+ link : '/settings' ,
46
+ func : ( ) => handleCardClick ( 2 ) ,
47
+ } ,
48
+ {
49
+ label : 'Practical ways to reduce air pollution' ,
50
+ time : '1 min' ,
51
+ link : 'https://blog.airqo.net/' ,
52
+ func : ( ) => handleCardClick ( 3 ) ,
53
+ } ,
54
+ ] ;
32
55
33
56
useEffect ( ( ) => {
34
- dispatch ( completeTask ( 1 ) ) ;
35
- } , [ ] ) ;
57
+ const completedCards = cardCheckList . filter ( ( card , index ) => {
58
+ // Skip the disabled step
59
+ if ( steps [ index ] && steps [ index ] . disabled ) {
60
+ return false ;
61
+ }
62
+ return card . completed === true ;
63
+ } ) ;
64
+ setStep ( completedCards . length ) ;
65
+ } , [ cardCheckList , steps ] ) ;
36
66
37
67
const handleModel = ( ) => {
38
68
setOpen ( ! open ) ;
@@ -52,8 +82,8 @@ const Home = () => {
52
82
} ;
53
83
54
84
const handleCardClick = ( id ) => {
55
- if ( id === 4 ) {
56
- dispatch ( completeTask ( 4 ) ) ;
85
+ if ( id === 3 ) {
86
+ dispatch ( completeTask ( 3 ) ) ;
57
87
} else {
58
88
const card = cardCheckList . find ( ( card ) => card . id === id ) ;
59
89
if ( card ) {
@@ -70,33 +100,6 @@ const Home = () => {
70
100
}
71
101
} ;
72
102
73
- const steps = [
74
- {
75
- label : 'Introduction AirQo Analytics demo video' ,
76
- time : '1 min' ,
77
- link : '#' ,
78
- func : ( ) => handleModel ( ) ,
79
- } ,
80
- {
81
- label : 'Choose location you most interested in' ,
82
- time : '2 min' ,
83
- link : '/analytics' ,
84
- func : ( ) => handleCardClick ( 2 ) ,
85
- } ,
86
- {
87
- label : 'Complete your AirQo Analytics profile' ,
88
- time : '4 min' ,
89
- link : '/settings' ,
90
- func : ( ) => handleCardClick ( 3 ) ,
91
- } ,
92
- {
93
- label : 'Practical ways to reduce air pollution' ,
94
- time : '1 min' ,
95
- link : 'https://blog.airqo.net/' ,
96
- func : ( ) => handleCardClick ( 4 ) ,
97
- } ,
98
- ] ;
99
-
100
103
return (
101
104
< Layout noBorderBottom pageTitle = 'Home' >
102
105
{ checkListStatus === 'loading' && checkListData . length === 0 ? (
@@ -124,8 +127,8 @@ const Home = () => {
124
127
125
128
< div className = 'w-full grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-5' >
126
129
{ steps . map ( ( step , index ) => {
127
- if ( index === 0 ) {
128
- return null ; // Skip displaying the card for the first step
130
+ if ( step . disabled ) {
131
+ return null ;
129
132
}
130
133
131
134
const card = cardCheckList . find ( ( card ) => card . id === index + 1 ) ;
@@ -140,8 +143,7 @@ const Home = () => {
140
143
< div
141
144
key = { index }
142
145
className = 'w-full h-[250px] flex flex-col justify-between items-start border-[0.5px] rounded-xl border-grey-150 py-5 px-3 space-y-5 focus:outline-blue-600 focus:ring-2 focus:shadow-lg focus:border-blue-600'
143
- tabIndex = { 0 }
144
- >
146
+ tabIndex = { 0 } >
145
147
< div className = 'w-full' >
146
148
{ card && card . completed === true ? (
147
149
< div className = 'w-14 h-14 flex justify-center items-center rounded-full bg-blue-900' >
@@ -150,9 +152,8 @@ const Home = () => {
150
152
) : (
151
153
< div
152
154
className = 'text-base w-14 h-14 flex justify-center items-center font-medium rounded-full'
153
- style = { { background : '#F5F5FF' } }
154
- >
155
- < span className = 'text-blue-600' > { index + 1 } </ span >
155
+ style = { { background : '#F5F5FF' } } >
156
+ < span className = 'text-blue-600' > { index === 0 ? index + 1 : index } </ span >
156
157
</ div >
157
158
) }
158
159
</ div >
@@ -167,8 +168,7 @@ const Home = () => {
167
168
< a
168
169
onClick = { step . func }
169
170
className = { statusColor }
170
- target = { index === 3 ? '_blank' : '' }
171
- >
171
+ target = { index === 3 ? '_blank' : '' } >
172
172
{ card && card . status === 'inProgress' ? 'Resume' : statusText }
173
173
</ a >
174
174
</ Link >
@@ -194,14 +194,12 @@ const Home = () => {
194
194
< Button
195
195
path = '/analytics'
196
196
className = 'bg-blue-900 text-white rounded-lg w-32 h-12'
197
- dataTestId = 'get-started-button'
198
- >
197
+ dataTestId = 'get-started-button' >
199
198
Start here
200
199
</ Button >
201
200
< a
202
201
onClick = { handleModel }
203
- className = 'text-blue-600 text-sm font-normal mt-2 cursor-pointer hidden'
204
- >
202
+ className = 'text-blue-600 text-sm font-normal mt-2 cursor-pointer hidden' >
205
203
Show me how
206
204
</ a >
207
205
</ div >
@@ -210,12 +208,10 @@ const Home = () => {
210
208
className = 'rounded-md p-9 relative'
211
209
style = { {
212
210
background : '#145DFF08' ,
213
- } }
214
- >
211
+ } } >
215
212
< div
216
213
onClick = { handleModel }
217
- className = 'absolute z-50 inset-0 flex items-center justify-center cursor-pointer hidden'
218
- >
214
+ className = 'absolute z-50 inset-0 flex items-center justify-center cursor-pointer hidden' >
219
215
< PlayIcon />
220
216
</ div >
221
217
< Image src = { AnalyticsImage } alt = 'Analytics Image' width = { 600 } height = { 350 } />
0 commit comments