2025-12-25 11:19:43 +00:00
|
|
|
import { useEffect, useState } from 'react';
|
feat: Visual masterpiece - true light mode & premium UI
🎨 **True Light/Dark Mode**
- Implemented proper light mode with inverted color scheme
- Smooth theme transitions (0.3s ease)
- Light mode colors: white backgrounds, dark text, vibrant accents
- System theme detection with proper class application
🌈 **Enhanced Theme System**
- 4 color themes work in both light and dark modes
- Cyber (cyan/magenta), Ocean (blue/teal), Forest (green/lime), Sunset (orange/purple)
- Theme-specific glassmorphism effects
- Proper contrast in light mode
✨ **Premium Animations**
- Float, glow-pulse, slide-in, scale-in, rotate-in animations
- Smooth page transitions
- Hover effects with depth (lift, glow, scale)
- Micro-interactions on all interactive elements
🎯 **Visual Polish**
- Enhanced glassmorphism for light/dark modes
- Custom scrollbar with theme colors
- Beautiful text selection
- Focus indicators for accessibility
- Premium utility classes
🔧 **Technical Improvements**
- Updated UIStore to properly apply light/dark classes
- Added data-theme attribute for CSS targeting
- Smooth scroll behavior
- Optimized transitions
The app is now a visual masterpiece with perfect light/dark mode support!
2026-01-11 01:32:21 +00:00
|
|
|
import '@/styles/premium-utilities.css';
|
feat: Major visual improvements - premium design system
🎨 **Enhanced Glassmorphism**
- Added radial gradients to glass-hud
- Improved shadows with multiple layers
- Better light mode glass effects
- Inset highlights for depth
✨ **Premium Visual Effects**
- Neon glow effects (cyan, magenta)
- Premium gradients for all themes
- Enhanced borders with glow
- Depth shadows (3 levels)
- Frosted glass variants (strong, subtle)
🎯 **Interactive Components**
- Premium button with shine effect
- Enhanced card hover states
- Smooth transitions everywhere
- Text glow and shadow effects
💎 **New Utility Classes**
- .neon-glow-cyan, .neon-glow-magenta
- .gradient-cyber, ocean, forest, sunset
- .border-glow, .shadow-premium
- .depth-1, depth-2, depth-3
- .glass-strong, .glass-subtle
- .btn-premium, .card-premium
- .interactive, .text-glow
The app now has a truly premium, polished visual design!
2026-01-11 01:40:52 +00:00
|
|
|
import '@/styles/visual-enhancements.css';
|
2025-12-08 18:57:54 +00:00
|
|
|
|
2026-01-15 16:56:26 +00:00
|
|
|
import { useQueryClient } from '@tanstack/react-query';
|
2025-12-26 08:11:41 +00:00
|
|
|
import { useAuthStore } from '@/features/auth/store/authStore';
|
2026-01-07 18:39:21 +00:00
|
|
|
|
2025-12-03 21:56:50 +00:00
|
|
|
import { useUIStore } from '@/stores/ui';
|
|
|
|
|
import { ErrorBoundary } from '@/components/ErrorBoundary';
|
|
|
|
|
import { PWAInstallBanner } from '@/components/pwa/PWAInstallBanner';
|
2025-12-17 14:15:45 +00:00
|
|
|
import { ToastProvider } from '@/components/feedback/ToastProvider';
|
2026-01-11 15:30:43 +00:00
|
|
|
import { OfflineIndicator } from '@/components/OfflineIndicator';
|
2025-12-03 21:56:50 +00:00
|
|
|
import { AppRouter } from '@/router';
|
2025-12-22 21:56:37 +00:00
|
|
|
import { csrfService } from '@/services/csrf';
|
2025-12-25 11:19:43 +00:00
|
|
|
import { useGlobalKeyboardShortcuts } from '@/hooks/useGlobalKeyboardShortcuts';
|
|
|
|
|
import { KeyboardShortcutsHelp } from '@/components/keyboard/KeyboardShortcutsHelp';
|
2025-12-25 12:43:01 +00:00
|
|
|
import { useStateHydration } from '@/utils/stateHydration';
|
2025-12-25 12:45:49 +00:00
|
|
|
import { useQueryInvalidation } from '@/hooks/useQueryInvalidation';
|
2026-01-15 16:56:26 +00:00
|
|
|
import { setupReactQuerySync } from '@/utils/reactQuerySync';
|
2026-01-07 09:35:43 +00:00
|
|
|
import { logger } from '@/utils/logger';
|
2025-12-03 21:56:50 +00:00
|
|
|
|
|
|
|
|
export function App() {
|
|
|
|
|
const { refreshUser } = useAuthStore();
|
2025-12-25 11:15:58 +00:00
|
|
|
const { theme, setTheme, language, setLanguage } = useUIStore();
|
2025-12-25 11:19:43 +00:00
|
|
|
const [showKeyboardHelp, setShowKeyboardHelp] = useState(false);
|
2026-01-15 16:56:26 +00:00
|
|
|
const queryClient = useQueryClient();
|
2025-12-25 11:19:43 +00:00
|
|
|
|
|
|
|
|
// FE-COMP-022: Enable global keyboard shortcuts
|
|
|
|
|
useGlobalKeyboardShortcuts({
|
|
|
|
|
enabled: true,
|
|
|
|
|
onHelpOpen: () => setShowKeyboardHelp(true),
|
|
|
|
|
});
|
2025-12-03 21:56:50 +00:00
|
|
|
|
2025-12-25 12:43:01 +00:00
|
|
|
// FE-STATE-003: Hydrate state from server on app load
|
feat: Visual masterpiece - true light mode & premium UI
🎨 **True Light/Dark Mode**
- Implemented proper light mode with inverted color scheme
- Smooth theme transitions (0.3s ease)
- Light mode colors: white backgrounds, dark text, vibrant accents
- System theme detection with proper class application
🌈 **Enhanced Theme System**
- 4 color themes work in both light and dark modes
- Cyber (cyan/magenta), Ocean (blue/teal), Forest (green/lime), Sunset (orange/purple)
- Theme-specific glassmorphism effects
- Proper contrast in light mode
✨ **Premium Animations**
- Float, glow-pulse, slide-in, scale-in, rotate-in animations
- Smooth page transitions
- Hover effects with depth (lift, glow, scale)
- Micro-interactions on all interactive elements
🎯 **Visual Polish**
- Enhanced glassmorphism for light/dark modes
- Custom scrollbar with theme colors
- Beautiful text selection
- Focus indicators for accessibility
- Premium utility classes
🔧 **Technical Improvements**
- Updated UIStore to properly apply light/dark classes
- Added data-theme attribute for CSS targeting
- Smooth scroll behavior
- Optimized transitions
The app is now a visual masterpiece with perfect light/dark mode support!
2026-01-11 01:32:21 +00:00
|
|
|
useStateHydration({
|
2025-12-25 12:43:01 +00:00
|
|
|
hydrateAuth: true,
|
|
|
|
|
hydrateLibrary: false, // Can be enabled if needed
|
|
|
|
|
hydrateChat: false, // Can be enabled if needed
|
|
|
|
|
requireAuth: false, // Hydrate auth even if not authenticated (to check status)
|
|
|
|
|
});
|
|
|
|
|
|
2025-12-25 12:45:49 +00:00
|
|
|
// FE-STATE-004: Listen for query invalidation events
|
|
|
|
|
useQueryInvalidation();
|
|
|
|
|
|
2026-01-15 16:56:26 +00:00
|
|
|
// Action 2.3.1.2: Initialize React Query cache synchronization across tabs
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const cleanup = setupReactQuerySync(queryClient, {
|
|
|
|
|
enabled: true,
|
|
|
|
|
channelName: 'veza-react-query-sync',
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return cleanup;
|
|
|
|
|
}, [queryClient]);
|
|
|
|
|
|
2025-12-03 21:56:50 +00:00
|
|
|
// Initialiser l'application
|
|
|
|
|
useEffect(() => {
|
2026-01-07 09:35:43 +00:00
|
|
|
// CRITIQUE FIX #18: refreshUser est maintenant appelé par useStateHydration
|
|
|
|
|
// Ne pas appeler refreshUser ici pour éviter les appels multiples
|
|
|
|
|
// useStateHydration gère déjà l'hydratation de l'état d'authentification
|
|
|
|
|
// Ce useEffect ne fait plus qu'initialiser les autres aspects de l'app
|
2026-01-07 18:39:21 +00:00
|
|
|
|
2025-12-22 21:56:37 +00:00
|
|
|
// Récupérer le token CSRF si l'utilisateur est déjà authentifié
|
|
|
|
|
// (refreshUser() est asynchrone, donc on vérifie après un court délai)
|
|
|
|
|
const checkAndFetchCSRF = async () => {
|
|
|
|
|
// Attendre un peu pour que refreshUser() se termine
|
2026-01-13 18:47:57 +00:00
|
|
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
2025-12-22 21:56:37 +00:00
|
|
|
const { isAuthenticated } = useAuthStore.getState();
|
|
|
|
|
if (isAuthenticated) {
|
|
|
|
|
csrfService.refreshToken().catch((error) => {
|
2026-01-07 09:35:43 +00:00
|
|
|
logger.warn('Failed to fetch CSRF token on app init', {
|
2026-01-07 18:39:21 +00:00
|
|
|
error: error instanceof Error ? error.message : String(error),
|
|
|
|
|
stack: error instanceof Error ? error.stack : undefined,
|
2026-01-07 09:35:43 +00:00
|
|
|
});
|
2025-12-22 21:56:37 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
checkAndFetchCSRF();
|
2025-12-03 21:56:50 +00:00
|
|
|
|
2025-12-25 11:13:29 +00:00
|
|
|
// Appliquer le thème au chargement (le store persist le fait déjà, mais on s'assure qu'il est appliqué)
|
2026-01-11 15:30:43 +00:00
|
|
|
// Forcer dark mode par défaut si pas encore défini
|
|
|
|
|
if (!theme || theme === 'system') {
|
|
|
|
|
const root = document.documentElement;
|
2026-01-13 18:47:57 +00:00
|
|
|
if (
|
|
|
|
|
!root.classList.contains('dark') &&
|
|
|
|
|
!root.classList.contains('light')
|
|
|
|
|
) {
|
2026-01-11 15:30:43 +00:00
|
|
|
setTheme('dark');
|
|
|
|
|
} else {
|
|
|
|
|
setTheme(theme);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
setTheme(theme);
|
|
|
|
|
}
|
2025-12-25 11:15:58 +00:00
|
|
|
|
|
|
|
|
// Synchroniser la langue avec i18n au chargement
|
|
|
|
|
if (typeof window !== 'undefined' && window.i18n) {
|
|
|
|
|
const currentLang = window.i18n.language || language;
|
|
|
|
|
if (currentLang !== language) {
|
|
|
|
|
window.i18n.changeLanguage(language);
|
|
|
|
|
} else if (language !== currentLang) {
|
|
|
|
|
setLanguage(currentLang as 'en' | 'fr');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, [refreshUser, setTheme, theme, language, setLanguage]);
|
2025-12-25 11:13:29 +00:00
|
|
|
|
|
|
|
|
// Écouter les changements de préférence système pour le mode 'system'
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (theme !== 'system') return;
|
|
|
|
|
|
|
|
|
|
const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
|
|
|
|
|
const handleChange = (e: MediaQueryListEvent) => {
|
|
|
|
|
const root = document.documentElement;
|
|
|
|
|
if (e.matches) {
|
|
|
|
|
root.classList.add('dark');
|
|
|
|
|
} else {
|
|
|
|
|
root.classList.remove('dark');
|
2025-12-03 21:56:50 +00:00
|
|
|
}
|
2025-12-25 11:13:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Écouter les changements
|
|
|
|
|
if (mediaQuery.addEventListener) {
|
|
|
|
|
mediaQuery.addEventListener('change', handleChange);
|
|
|
|
|
} else {
|
|
|
|
|
// Fallback pour les navigateurs plus anciens
|
|
|
|
|
mediaQuery.addListener(handleChange);
|
2025-12-03 21:56:50 +00:00
|
|
|
}
|
2025-12-25 11:13:29 +00:00
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
if (mediaQuery.removeEventListener) {
|
|
|
|
|
mediaQuery.removeEventListener('change', handleChange);
|
|
|
|
|
} else {
|
|
|
|
|
mediaQuery.removeListener(handleChange);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}, [theme]);
|
2025-12-03 21:56:50 +00:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<ErrorBoundary>
|
2025-12-17 14:15:45 +00:00
|
|
|
<ToastProvider>
|
2026-01-11 15:30:43 +00:00
|
|
|
{/* Offline/Online Status Indicator */}
|
|
|
|
|
<OfflineIndicator />
|
2025-12-17 14:15:45 +00:00
|
|
|
<AppRouter />
|
|
|
|
|
{/* PWA Install Banner */}
|
|
|
|
|
<PWAInstallBanner />
|
2025-12-25 11:19:43 +00:00
|
|
|
{/* Keyboard Shortcuts Help */}
|
|
|
|
|
<KeyboardShortcutsHelp
|
|
|
|
|
open={showKeyboardHelp}
|
|
|
|
|
onClose={() => setShowKeyboardHelp(false)}
|
|
|
|
|
/>
|
2025-12-17 14:15:45 +00:00
|
|
|
</ToastProvider>
|
2025-12-03 21:56:50 +00:00
|
|
|
</ErrorBoundary>
|
|
|
|
|
);
|
|
|
|
|
}
|