@@ -18,7 +18,7 @@ import { docsLink } from '@/config/site';
1818import { getFactorIcon } from '@/lib/analytics/factor-icon' ;
1919import { getFactorRole , isScoreIndicator } from '@/lib/analytics/factor-role' ;
2020import { isRootRiskIndicator } from '@/lib/analytics/root-indicator' ;
21- import { getFactorNameBySlug , getLatestDate } from '@/lib/analytics/utils' ;
21+ import { getFactorNameBySlug , getLatestDate , filterSubIndicatorsForView } from '@/lib/analytics/utils' ;
2222import { GraphQL } from '@/lib/api' ;
2323import { type JsonScalar } from '@/lib/types' ;
2424import { cn , parsePeriodString } from '@/lib/utils' ;
@@ -304,6 +304,7 @@ export function OutputWindow({
304304 data = { data }
305305 boundary = { boundary }
306306 indicator = { indicator }
307+ view = { view }
307308 getDescription = { getDescription }
308309 />
309310 </ div >
@@ -512,6 +513,7 @@ export function OutputWindow({
512513 data = { data }
513514 boundary = { boundary }
514515 indicator = { indicator }
516+ view = { view }
515517 getDescription = { getDescription }
516518 />
517519 </ div >
@@ -532,12 +534,14 @@ function OtherFactorScores({
532534 data,
533535 boundary,
534536 indicator,
537+ view,
535538 getDescription,
536539} : {
537540 factorData : Indicator [ ] | undefined ;
538541 data : JsonScalar ;
539542 boundary : string ;
540543 indicator : string ;
544+ view : string ;
541545 getDescription : ( slug : string ) => string | null | undefined ;
542546} ) {
543547 const clonedData = structuredClone ( data ) ;
@@ -547,12 +551,15 @@ function OtherFactorScores({
547551 delete clonedData [ 'district' ] ;
548552 delete clonedData [ 'district-code' ] ;
549553
550- const FactorVariables = Object . keys ( clonedData ) ;
554+ const FactorVariables = filterSubIndicatorsForView (
555+ Object . keys ( clonedData ) . filter (
556+ ( scoreType ) => typeof data [ scoreType ] === 'object'
557+ ) ,
558+ view ,
559+ indicator
560+ ) ;
551561
552- // TODO: Change the filteration to the factor specific structure for it to work with data having objects
553- return FactorVariables . filter (
554- ( scoreType ) => typeof data [ scoreType ] === 'object'
555- ) . map ( ( scoreType ) => (
562+ return FactorVariables . map ( ( scoreType ) => (
556563 < div key = { scoreType } className = " flex items-center gap-4" >
557564 { /* //change */ }
558565 { getFactorRole ( scoreType ) && (
0 commit comments