11import React from 'react' ;
22import { useQuery } from 'react-query' ;
33import { Loader } from '@scality/core-ui/dist/components/loader/Loader.component' ;
4+ import { useAuth } from '../auth/AuthProvider' ;
45import { getAlerts } from './services/alertManager' ;
56import { AlertContext } from './alertContext' ;
67/**
@@ -18,13 +19,18 @@ export default function AlertProvider({
1819 alertManagerUrl : string ;
1920 children : React . ReactNode ;
2021} ) {
21- const query = useQuery ( 'activeAlerts' , ( ) => getAlerts ( alertManagerUrl ) , {
22- // refetch the alerts every 10 seconds
23- refetchInterval : 30000 ,
24- // TODO manage this refresh interval globally
25- // avoid stucking at the hard loading state before alertmanager is ready
26- initialData : [ ] ,
27- } ) ;
22+ const { userData } = useAuth ( ) ;
23+ const query = useQuery (
24+ 'activeAlerts' ,
25+ ( ) => getAlerts ( alertManagerUrl , userData ?. token ) ,
26+ {
27+ // refetch the alerts every 30 seconds
28+ refetchInterval : 30000 ,
29+ // TODO manage this refresh interval globally
30+ // avoid stucking at the hard loading state before alertmanager is ready
31+ initialData : [ ] ,
32+ } ,
33+ ) ;
2834 return (
2935 < AlertContext . Provider value = { { ...query } } >
3036 { query . status === 'loading' && (
0 commit comments