veza/apps/web/src/features/player/components/PlayerQueue.stories.tsx
senke de12f5036c fix(web): resolve all 568 TypeScript errors — tsc --noEmit now passes with zero errors
Major categories fixed:
- TS6133 (188): Remove unused imports (React, icons, types) and variables
- TS2322 (222): Fix type mismatches in stories (satisfies Meta -> const meta: Meta),
  add nullish coalescing for optional values, fix component prop types
- TS2345 (43): Fix argument type mismatches with proper null checks and type narrowing
- TS2741 (21): Add missing required properties to mock/story data
- TS2339 (19): Fix property access on incorrect types, add type guards
- TS2353 (13): Remove extra properties from object literals or extend interfaces
- TS2352 (11): Fix type conversion chains
- TS2307 (9): Fix import paths and module references
- Other (42): Fix implicit any, possibly undefined, export declarations

Vite build and tsc --noEmit both pass cleanly.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-13 00:32:08 +01:00

82 lines
2.5 KiB
TypeScript

import type { Meta, StoryObj } from '@storybook/react';
import { PlayerQueue } from './PlayerQueue';
import { usePlayerStore } from '../store/playerStore';
import { useEffect } from 'react';
const meta: Meta<typeof PlayerQueue> = {
title: 'Components/Features/Player/PlayerQueue',
component: PlayerQueue,
parameters: {
layout: 'padded',
},
tags: ['autodocs'],
argTypes: {
onClose: { action: 'onClose' },
onPlay: { action: 'onPlay' },
},
};
export default meta;
type Story = StoryObj<typeof PlayerQueue>;
const mockTracks = [
{ id: '1', title: 'Start Me Up', artist: 'The Rolling Stones', cover: 'https://picsum.photos/200', duration: 200, url: '' },
{ id: '2', title: 'Bohemian Rhapsody', artist: 'Queen', cover: 'https://picsum.photos/201', duration: 354, url: '' },
{ id: '3', title: 'Hotel California', artist: 'Eagles', cover: 'https://picsum.photos/202', duration: 391, url: '' },
];
const StoreInitializer = ({ tracks, currentIndex = 0 }: { tracks: any[], currentIndex?: number }) => {
const { addToQueue, clearQueue } = usePlayerStore();
useEffect(() => {
clearQueue();
// We add tracks one by one or batch if supported, here we simluate adding
// Note: usePlayerStore actions might need adjustment if they don't support direct manipulation for stories
// But addToQueue takes Track[].
// We clear first
usePlayerStore.setState({ queue: [], currentIndex: -1 });
// Set state directly for storybook purposes to ensure consistency
usePlayerStore.setState({
queue: tracks,
currentIndex: currentIndex,
currentTrack: tracks[currentIndex]
});
}, [tracks, currentIndex, addToQueue, clearQueue]);
return null;
};
export const Default: Story = {
args: {
isOpen: true,
},
decorators: [
(Story) => (
<>
<StoreInitializer tracks={mockTracks} currentIndex={0} />
<div className="h-[600px] w-full relative bg-gray-900 overflow-hidden">
<Story />
</div>
</>
),
],
};
export const Empty: Story = {
args: {
isOpen: true,
},
decorators: [
(Story) => (
<>
<StoreInitializer tracks={[]} />
<div className="h-[600px] w-full relative bg-gray-900 overflow-hidden">
<Story />
</div>
</>
),
],
};