Complete stabilization pass bringing all 3 stacks to green: Frontend (apps/web/): - Fix TypeScript nullability in useSeason.ts, useTimeOfDay.ts hooks - Disable no-undef in ESLint config (TypeScript handles it; JSX misidentified) - Rename 306 story imports from @storybook/react to @storybook/react-vite - Fix conditional hook call in useMediaQuery.ts useIsTablet - Move useQuery to top of LoginPage.tsx component - Remove useless try/catch in GearFormModal.tsx - Fix stale closure in ResetPasswordPage.tsx handleChange - Make Storybook decorators (withRouter, withQueryClient, withToast, withAudio) no-ops since global StorybookDecorator already provides these — prevents nested Router / duplicate provider crashes in vitest-browser - Fix nested MemoryRouter in 3 page stories (TrackDetail, PlaylistDetail, UserProfile) - Update i18n initialization in test setup (await init before changeLanguage) - Update ~30 test assertions from English to French to match i18n translations - Update test assertions to match SUMI V3 design changes (shadow vs border) - Fix remaining story type errors (PlayerError, PlaylistBatchActions, TrackFilters, VirtualizedChatMessages) Backend (veza-backend-api/): - Fix response_test.go RespondWithAppError signature (2 args, not 3) - Fix TestErrorContractAuthEndpoints expected error codes (ErrCodeUnauthorized vs ErrCodeInvalidCredentials) - Fix TestTrackHandler_GetTrackLikes_Success missing auth middleware setup - Fix TestPlaybackAnalyticsService_GetTrackStats k-anonymity threshold (needs 5 unique users, not 1) - Replace NOW() PostgreSQL function with time.Now() parameter in marketplace service for SQLite test compatibility - Add missing AutoMigrate entries in marketplace_test.go (ProductImage, ProductPreview, ProductLicense, ProductReview) Results: - Frontend TypeCheck: 617 errors -> 0 errors - Frontend ESLint: 349 errors -> 0 errors - Frontend Vitest: 196 failing tests -> 1 skipped (3396/3397 passing) - Backend go vet: 1 error -> 0 errors - Backend tests: 5 failing -> all 13 packages passing - Rust: 150/150 tests passing (unchanged) - Storybook audit: 0 errors across 1244 stories Triage report: docs/TRIAGE_REPORT.md Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
264 lines
11 KiB
TypeScript
264 lines
11 KiB
TypeScript
import React, { useState } from 'react';
|
|
import { useAudio } from '../../context/AudioContext';
|
|
import { MiniPlayer } from '../player/MiniPlayer';
|
|
import { FullPlayer } from '../player/FullPlayer';
|
|
import {
|
|
X,
|
|
ListMusic,
|
|
Play,
|
|
GripVertical,
|
|
Trash2,
|
|
ArrowUpToLine,
|
|
ListPlus,
|
|
Clock,
|
|
Heart,
|
|
} from 'lucide-react';
|
|
import { useToast } from '../../components/feedback/ToastProvider';
|
|
import { Button } from '../ui/button';
|
|
|
|
export const AudioPlayer: React.FC = () => {
|
|
const {
|
|
currentTrack,
|
|
queue,
|
|
history,
|
|
reorderQueue,
|
|
playTrack,
|
|
playNext,
|
|
removeFromQueue,
|
|
addToQueue,
|
|
clearQueue,
|
|
} = useAudio();
|
|
const { addToast } = useToast();
|
|
const [isImmersive, setIsImmersive] = useState(false);
|
|
const [showQueue, setShowQueue] = useState(false);
|
|
const [queueTab, setQueueTab] = useState<'up-next' | 'history'>('up-next');
|
|
const [draggedItemIndex, setDraggedItemIndex] = useState<number | null>(null);
|
|
|
|
if (!currentTrack) return null;
|
|
|
|
// Queue Drag Handlers
|
|
const onDragStart = (e: React.DragEvent, index: number) => {
|
|
setDraggedItemIndex(index);
|
|
e.dataTransfer.effectAllowed = 'move';
|
|
const ghost = document.createElement('div');
|
|
ghost.style.opacity = '0';
|
|
document.body.appendChild(ghost);
|
|
e.dataTransfer.setDragImage(ghost, 0, 0);
|
|
setTimeout(() => document.body.removeChild(ghost), 0);
|
|
};
|
|
|
|
const onDragOver = (e: React.DragEvent, index: number) => {
|
|
e.preventDefault();
|
|
if (draggedItemIndex === null || draggedItemIndex === index) return;
|
|
reorderQueue(draggedItemIndex, index);
|
|
setDraggedItemIndex(index);
|
|
};
|
|
|
|
const onDragEnd = () => setDraggedItemIndex(null);
|
|
|
|
return (
|
|
<>
|
|
{/* IMMERSIVE PLAYER OVERLAY */}
|
|
{isImmersive && <FullPlayer onClose={() => setIsImmersive(false)} />}
|
|
|
|
{/* QUEUE DRAWER */}
|
|
{showQueue && !isImmersive && (
|
|
<div className="fixed bottom-24 right-4 w-full md:w-96 bg-card/95 backdrop-blur-xl rounded-xl shadow-2xl z-40 overflow-hidden animate-slideUp max-h-layout-panel flex flex-col ring-1 ring-white/10">
|
|
<div className="flex items-center justify-between p-4 border-b border-border bg-muted/80">
|
|
<h3 className="font-bold text-foreground text-sm tracking-wide flex items-center gap-2">
|
|
<ListMusic className="w-4 h-4 text-muted-foreground" /> PLAY QUEUE
|
|
</h3>
|
|
<X
|
|
className="w-5 h-5 text-muted-foreground cursor-pointer hover:text-foreground"
|
|
onClick={() => setShowQueue(false)}
|
|
/>
|
|
</div>
|
|
|
|
<div className="flex-1 flex flex-col min-h-0">
|
|
<div className="flex border-b border-border bg-muted/30">
|
|
<button
|
|
className={`flex-1 py-4 text-xs font-bold uppercase tracking-wider transition-colors ${queueTab === 'up-next' ? 'text-primary border-b-2 border-primary bg-muted/50' : 'text-muted-foreground hover:text-foreground'}`}
|
|
onClick={() => setQueueTab('up-next')}
|
|
>
|
|
Up Next ({queue.length})
|
|
</button>
|
|
<button
|
|
className={`flex-1 py-4 text-xs font-bold uppercase tracking-wider transition-colors ${queueTab === 'history' ? 'text-primary border-b-2 border-primary bg-muted/50' : 'text-muted-foreground hover:text-foreground'}`}
|
|
onClick={() => setQueueTab('history')}
|
|
>
|
|
History
|
|
</button>
|
|
</div>
|
|
|
|
<div className="flex-1 overflow-y-auto custom-scrollbar p-0">
|
|
{queueTab === 'up-next' && (
|
|
<>
|
|
<div className="p-4 bg-primary/5 border-b border-border/30">
|
|
<div className="text-xs font-bold text-muted-foreground uppercase tracking-wider mb-2">
|
|
Now Playing
|
|
</div>
|
|
<div className="flex items-center gap-4 group relative">
|
|
<img
|
|
src={currentTrack.coverUrl}
|
|
alt={`Cover art for ${currentTrack.title} by ${currentTrack.artist}`}
|
|
className="w-12 h-12 rounded shadow-lg"
|
|
/>
|
|
<div className="flex-1 min-w-0">
|
|
<div className="text-sm font-bold text-foreground truncate">
|
|
{currentTrack.title}
|
|
</div>
|
|
<div className="text-xs text-muted-foreground truncate">
|
|
{currentTrack.artist}
|
|
</div>
|
|
</div>
|
|
<button
|
|
className="p-2 hover:bg-white/10 rounded-full text-muted-foreground hover:text-destructive"
|
|
onClick={() => addToast('Saved to Library', 'success')}
|
|
>
|
|
<Heart className="w-4 h-4" />
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div className="p-2 space-y-1">
|
|
{queue.length === 0 && (
|
|
<div className="text-center text-muted-foreground py-12 flex flex-col items-center">
|
|
<ListMusic className="w-8 h-8 mb-2 opacity-50" />
|
|
<p className="text-sm italic">Queue is empty</p>
|
|
</div>
|
|
)}
|
|
|
|
{queue.map((track, i) => (
|
|
<div
|
|
key={track.id}
|
|
draggable
|
|
onDragStart={(e) => onDragStart(e, i)}
|
|
onDragOver={(e) => onDragOver(e, i)}
|
|
onDragEnd={onDragEnd}
|
|
className={`flex items-center gap-4 p-2 rounded-lg group transition-colors border border-transparent ${draggedItemIndex === i ? 'bg-primary/10 border-primary/50' : 'hover:bg-white/5 hover:border-white/5'}`}
|
|
>
|
|
<div className="cursor-grab active:cursor-grabbing text-muted-foreground hover:text-foreground p-1">
|
|
<GripVertical className="w-4 h-4" />
|
|
</div>
|
|
<div className="relative w-8 h-8 rounded overflow-hidden flex-shrink-0">
|
|
<img
|
|
src={track.coverUrl}
|
|
alt={`Cover art for ${track.title} by ${track.artist}`}
|
|
className="w-full h-full object-cover"
|
|
/>
|
|
<div
|
|
className="absolute inset-0 bg-black/50 hidden group-hover:flex items-center justify-center cursor-pointer"
|
|
onClick={() => playTrack(track)}
|
|
>
|
|
<Play className="w-3 h-3 text-foreground fill-current" />
|
|
</div>
|
|
</div>
|
|
<div className="flex-1 min-w-0 select-none">
|
|
<div className="text-sm font-medium text-foreground group-hover:text-foreground truncate">
|
|
{track.title}
|
|
</div>
|
|
<div className="text-xs text-muted-foreground truncate">
|
|
{track.artist}
|
|
</div>
|
|
</div>
|
|
|
|
<div className="flex items-center opacity-0 group-hover:opacity-100 transition-opacity gap-1">
|
|
<button
|
|
className="p-1.5 hover:text-foreground"
|
|
title="Play Next"
|
|
onClick={(e) => {
|
|
e.stopPropagation();
|
|
playNext(track);
|
|
removeFromQueue(track.id);
|
|
}}
|
|
>
|
|
<ArrowUpToLine className="w-3.5 h-3.5" />
|
|
</button>
|
|
<button
|
|
className="p-1.5 hover:text-destructive"
|
|
title="Remove"
|
|
onClick={(e) => {
|
|
e.stopPropagation();
|
|
removeFromQueue(track.id);
|
|
}}
|
|
>
|
|
<Trash2 className="w-3.5 h-3.5" />
|
|
</button>
|
|
</div>
|
|
</div>
|
|
))}
|
|
</div>
|
|
</>
|
|
)}
|
|
|
|
{queueTab === 'history' && (
|
|
<div className="p-2 space-y-1">
|
|
{history.length === 0 && (
|
|
<div className="text-center text-muted-foreground py-12 flex flex-col items-center">
|
|
<Clock className="w-8 h-8 mb-2 opacity-50" />
|
|
<p className="text-sm italic">No history yet</p>
|
|
</div>
|
|
)}
|
|
{[...history].reverse().map((track, i) => (
|
|
<div
|
|
key={`${track.id}-${i}`}
|
|
className="flex items-center gap-4 p-2 rounded-lg hover:bg-white/5 group opacity-70 hover:opacity-100 transition-opacity"
|
|
>
|
|
<div className="w-8 h-8 rounded overflow-hidden flex-shrink-0 grayscale group-hover:grayscale-0 transition-all">
|
|
<img
|
|
src={track.coverUrl}
|
|
alt={`Cover art for ${track.title} by ${track.artist}`}
|
|
className="w-full h-full object-cover"
|
|
/>
|
|
</div>
|
|
<div className="flex-1 min-w-0">
|
|
<div className="text-sm font-medium text-foreground group-hover:text-foreground truncate">
|
|
{track.title}
|
|
</div>
|
|
<div className="text-xs text-muted-foreground truncate">
|
|
{track.artist}
|
|
</div>
|
|
</div>
|
|
<button
|
|
className="p-1.5 text-muted-foreground hover:text-foreground opacity-0 group-hover:opacity-100 transition-opacity"
|
|
onClick={() => {
|
|
addToQueue(track);
|
|
addToast('Added back to Queue');
|
|
}}
|
|
>
|
|
<ListPlus className="w-4 h-4" />
|
|
</button>
|
|
</div>
|
|
))}
|
|
</div>
|
|
)}
|
|
</div>
|
|
|
|
{queueTab === 'up-next' && queue.length > 0 && (
|
|
<div className="p-4 border-t border-border bg-muted">
|
|
<Button
|
|
variant="ghost"
|
|
size="sm"
|
|
className="w-full text-xs text-muted-foreground hover:text-destructive"
|
|
onClick={() => {
|
|
clearQueue();
|
|
addToast('Queue Cleared');
|
|
}}
|
|
>
|
|
Clear Queue
|
|
</Button>
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
)}
|
|
|
|
{/* MINI PLAYER BAR */}
|
|
<MiniPlayer
|
|
onExpand={() => setIsImmersive(true)}
|
|
onToggleQueue={() => setShowQueue(!showQueue)}
|
|
isQueueOpen={showQueue}
|
|
/>
|
|
</>
|
|
);
|
|
};
|