File tree Expand file tree Collapse file tree
src/pages/dashboard/services/PestAndDisease Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,10 +21,17 @@ interface FormattedRiskIndexData {
2121 [ day : string ] : DailyData
2222}
2323
24- const riskLevelMapping : { [ key : string ] : number } = {
25- 'low' : 0 ,
26- 'medium' : 1 ,
27- 'high' : 2 ,
24+ const riskLevelMapping = ( label : string ) : number => {
25+ switch ( label ) {
26+ case 'low' :
27+ return 0 ;
28+ case 'moderate' :
29+ return 1 ;
30+ case 'high' :
31+ return 2 ;
32+ default :
33+ return 0 ;
34+ }
2835} ;
2936
3037const riskLevelLabels = [ 'low' , 'medium' , 'high' ] ;
@@ -78,6 +85,12 @@ const RiskIndexPage = () => {
7885 }
7986 } , [ response ] ) ;
8087
88+ useEffect ( ( ) => {
89+ if ( formattedData ) {
90+ console . log ( formattedData ) ;
91+ }
92+ } , [ formattedData ] )
93+
8194 return (
8295 < >
8396 < ParcelSelectionModule > </ ParcelSelectionModule >
@@ -111,7 +124,7 @@ const RiskIndexPage = () => {
111124 < Box display = { 'flex' } flexDirection = { 'column' } gap = { 2 } >
112125 { Object . entries ( formattedData ) . map ( ( [ date , dailyData ] : [ string , DailyData ] ) => {
113126 const numericalRiskData = dailyData . riskIndex ?. map (
114- ( status ) => riskLevelMapping [ status ]
127+ ( status ) => riskLevelMapping ( status )
115128 ) . filter ( value => value !== undefined ) as number [ ] || [ ] ;
116129 return < Card key = { `id-date-${ date } ` } >
117130 < CardContent >
You can’t perform that action at this time.
0 commit comments