Files
Charon/frontend/src/main.tsx
GitHub Actions 6351a9bba3 feat: add CrowdSec API key status handling and warning component
- Implemented `getCrowdsecKeyStatus` API call to retrieve the current status of the CrowdSec API key.
- Created `CrowdSecKeyWarning` component to display warnings when the API key is rejected.
- Integrated `CrowdSecKeyWarning` into the Security page, ensuring it only shows when relevant.
- Updated i18n initialization in main.tsx to prevent race conditions during rendering.
- Enhanced authentication setup in tests to handle various response statuses more robustly.
- Adjusted security tests to accept broader error responses for import validation.
2026-02-04 09:17:25 +00:00

44 lines
1.4 KiB
TypeScript

import React from 'react'
import ReactDOM from 'react-dom/client'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import App from './App.tsx'
import { ThemeProvider } from './context/ThemeContext'
import { LanguageProvider } from './context/LanguageContext'
import i18n from './i18n'
import './index.css'
// Global query client with optimized defaults for performance
const queryClient = new QueryClient({
defaultOptions: {
queries: {
staleTime: 1000 * 30, // 30 seconds - reduces unnecessary refetches
gcTime: 1000 * 60 * 5, // 5 minutes garbage collection
refetchOnWindowFocus: false, // Prevents refetch when switching tabs
refetchOnReconnect: 'always', // Refetch when network reconnects
retry: 1, // Only retry failed requests once
},
},
})
// Wait for i18next to be fully initialized before rendering
// Prevents race condition where React renders before translations are loaded
const renderApp = () => {
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<QueryClientProvider client={queryClient}>
<ThemeProvider>
<LanguageProvider>
<App />
</LanguageProvider>
</ThemeProvider>
</QueryClientProvider>
</React.StrictMode>,
)
}
if (i18n.isInitialized) {
renderApp()
} else {
i18n.on('initialized', renderApp)
}