diff --git a/apps/web/src/components/ui/LazyComponent.tsx b/apps/web/src/components/ui/LazyComponent.tsx index 16435c553..36e8a26f5 100644 --- a/apps/web/src/components/ui/LazyComponent.tsx +++ b/apps/web/src/components/ui/LazyComponent.tsx @@ -243,23 +243,34 @@ export const LazyDashboard = createLazyComponent( 'Dashboard', ); export const LazyChat = createLazyComponent( - () => import('@/features/chat/pages/ChatPage'), + () => + import('@/features/chat/pages/ChatPage').then((m) => ({ + default: m.ChatPage, + })), undefined, 'Chat', ); -// CRITIQUE FIX #16: Tous les composants lazy utilisent maintenant la gestion d'erreur standardisée export const LazyLibrary = createLazyComponent( - () => import('@/features/library/pages/LibraryPage'), + () => + import('@/features/library/pages/LibraryPage').then((m) => ({ + default: m.LibraryPage, + })), undefined, 'Library', ); export const LazyProfile = createLazyComponent( - () => import('@/features/profile/pages/UserProfilePage'), + () => + import('@/features/profile/pages/UserProfilePage').then((m) => ({ + default: m.UserProfilePage, + })), undefined, 'Profile', ); export const LazySettings = createLazyComponent( - () => import('@/features/settings/pages/SettingsPage'), + () => + import('@/features/settings/pages/SettingsPage').then((m) => ({ + default: m.SettingsPage, + })), undefined, 'Settings', ); diff --git a/apps/web/src/features/player/components/GlobalPlayer.tsx b/apps/web/src/features/player/components/GlobalPlayer.tsx index adeeaa110..d64e11983 100644 --- a/apps/web/src/features/player/components/GlobalPlayer.tsx +++ b/apps/web/src/features/player/components/GlobalPlayer.tsx @@ -1,29 +1,31 @@ - -import React, { useState, useEffect } from 'react'; -import { useAudio } from '@/context/AudioContext'; +import React, { useState, useRef } from 'react'; +import { usePlayer } from '@/features/player/hooks/usePlayer'; +import { useKeyboardShortcuts } from '@/features/player/hooks/useKeyboardShortcuts'; import { Slider } from '@/components/ui/slider'; import { cn } from '@/lib/utils'; -import { Link } from 'react-router-dom'; import { - Play, Pause, SkipBack, SkipForward, Volume2, VolumeX, - Repeat, Shuffle, Heart, - Maximize2 + Heart, Maximize2, ListMusic, Volume2, VolumeX } from 'lucide-react'; +import { PlayerControls } from './PlayerControls'; +import { PlayerQueue } from './PlayerQueue'; +import { PlayerExpanded } from './PlayerExpanded'; +import { Button } from '@/components/ui/button'; -// Waveform Visualization (Randomized for now, as in desy example) +// Enhanced Waveform Visualization const Waveform = ({ playing }: { playing: boolean }) => { return ( -
- {Array.from({ length: 40 }).map((_, i) => ( +
+ {Array.from({ length: 24 }).map((_, i) => (
))} @@ -32,135 +34,226 @@ const Waveform = ({ playing }: { playing: boolean }) => { }; export function GlobalPlayer() { - const { - currentTrack, isPlaying, togglePlay, nextTrack, prevTrack, - volume, setVolume, progress, duration, seek, - } = useAudio(); + const audioRef = useRef(null); + + // Use the REAL player hook logic which connects to Zustand store + const player = usePlayer(audioRef); + + // Enable keyboard shortcuts + useKeyboardShortcuts(player); const [isHovered, setIsHovered] = useState(false); + const [isExpanded, setIsExpanded] = useState(false); + const [showQueue, setShowQueue] = useState(false); const formatTime = (seconds: number) => { - if (!seconds) return '0:00'; + if (!seconds && seconds !== 0) return '0:00'; const m = Math.floor(seconds / 60); const s = Math.floor(seconds % 60); return `${m}:${s.toString().padStart(2, '0')}`; }; - if (!currentTrack) return null; + const currentTrack = player.currentTrack; + + // Placeholder track for idle state + const idleTrack = { + id: 'idle', + title: 'System Online', + artist: 'Select a track to play', + cover: '', + duration: 0, + url: '' + }; + + const displayTrack = currentTrack || idleTrack; + const isIdle = !currentTrack; return ( -
setIsHovered(true)} - onMouseLeave={() => setIsHovered(false)} - > - {/* Main Glass Island */} -
+ <> +