@@ -5,7 +5,7 @@ import getBbox from '@turf/bbox';
55
66import Container from '#components/Container' ;
77import Link from '#components/Link' ;
8- import RiskImminentEvents from '#components/domain/RiskImminentEvents' ;
8+ import RiskImminentEvents , { type ImminentEventSource } from '#components/domain/RiskImminentEvents' ;
99import HistoricalDataChart from '#components/domain/HistoricalDataChart' ;
1010import BlockLoading from '#components/BlockLoading' ;
1111import useTranslation from '#hooks/useTranslation' ;
@@ -73,6 +73,40 @@ export function Component() {
7373 [ imminentEventCountsResponse ] ,
7474 ) ;
7575
76+ const defaultImminentEventSource = useMemo < ImminentEventSource | undefined > (
77+ ( ) => {
78+ if ( isNotDefined ( imminentEventCountsResponse ) ) {
79+ return undefined ;
80+ }
81+
82+ const {
83+ pdc,
84+ adam,
85+ gdacs,
86+ meteoswiss,
87+ } = imminentEventCountsResponse ;
88+
89+ if ( isDefined ( pdc ) && pdc > 0 ) {
90+ return 'pdc' ;
91+ }
92+
93+ if ( isDefined ( adam ) && adam > 0 ) {
94+ return 'wfpAdam' ;
95+ }
96+
97+ if ( isDefined ( gdacs ) && gdacs > 0 ) {
98+ return 'gdacs' ;
99+ }
100+
101+ if ( isDefined ( meteoswiss ) && meteoswiss > 0 ) {
102+ return 'meteoSwiss' ;
103+ }
104+
105+ return undefined ;
106+ } ,
107+ [ imminentEventCountsResponse ] ,
108+ ) ;
109+
76110 // NOTE: we always get 1 child in the response
77111 const riskResponse = countryRiskResponse ?. [ 0 ] ;
78112 const bbox = useMemo (
@@ -91,6 +125,7 @@ export function Component() {
91125 iso3 = { countryResponse . iso3 }
92126 title = { countryResponse . name }
93127 bbox = { bbox }
128+ defaultSource = { defaultImminentEventSource }
94129 />
95130 ) }
96131 < Container
0 commit comments