11import React , { useCallback , useEffect , useRef , useState } from 'react' ;
22
33import { Button , Separator } from '@douglasneuroinformatics/libui/components' ;
4- import { useTheme , useTranslation } from '@douglasneuroinformatics/libui/hooks' ;
4+ import { useNotificationsStore , useTheme , useTranslation } from '@douglasneuroinformatics/libui/hooks' ;
55import type { Theme } from '@douglasneuroinformatics/libui/hooks' ;
6- import type { Language } from '@opendatacapture/runtime-core' ;
6+ import type { Language , RuntimeNotification } from '@opendatacapture/runtime-core' ;
77import { $Json } from '@opendatacapture/schemas/core' ;
88import type { Json } from '@opendatacapture/schemas/core' ;
99import { FullscreenIcon , ZoomInIcon , ZoomOutIcon } from 'lucide-react' ;
@@ -20,6 +20,7 @@ export const InteractiveContent = React.memo<InteractiveContentProps>(function I
2020 bundle,
2121 onSubmit
2222} ) {
23+ const addNotification = useNotificationsStore ( ( store ) => store . addNotification ) ;
2324 const { changeLanguage, resolvedLanguage } = useTranslation ( ) ;
2425 const [ _ , updateTheme ] = useTheme ( ) ;
2526 const [ scale , setScale ] = useState ( 100 ) ;
@@ -80,6 +81,12 @@ export const InteractiveContent = React.memo<InteractiveContentProps>(function I
8081 return ( ) => document . removeEventListener ( 'done' , handleDoneEvent , false ) ;
8182 } , [ handleDoneEvent ] ) ;
8283
84+ useEffect ( ( ) => {
85+ const handler = ( event : CustomEvent < RuntimeNotification > ) => addNotification ( event . detail ) ;
86+ document . addEventListener ( 'addNotification' , handler , false ) ;
87+ return ( ) => document . removeEventListener ( 'addNotification' , handler , false ) ;
88+ } , [ ] ) ;
89+
8390 const dimensions = `${ ( 100 / scale ) * 100 } %` ;
8491
8592 return (
0 commit comments