import type { Meta, StoryObj } from '@storybook/react';
import { EquipmentDetailView, EquipmentDetailViewSkeleton } from './equipment-detail-view';
import { ToastProvider } from '@/components/feedback/ToastProvider';

const meta: Meta<typeof EquipmentDetailView> = {
  title: 'Components/Features/Inventory/EquipmentDetailView',
  component: EquipmentDetailView,
  parameters: { layout: 'fullscreen' },
  tags: ['autodocs'],
  decorators: [
    (Story) => (
      <ToastProvider>
        <div className="bg-background min-h-screen">
          <Story />
        </div>
      </ToastProvider>
    ),
  ],
};

export default meta;
type Story = StoryObj<typeof meta>;

const mockItem = {
  id: '1',
  name: 'Prophet-6',
  category: 'Synth',
  brand: 'Sequential',
  model: 'Desktop',
  serialNumber: 'SQ-P6-99281',
  purchaseDate: '2023-01-15',
  purchasePrice: 2499,
  currency: 'USD' as const,
  status: 'Active' as const,
  condition: 'Mint' as const,
  vendor: 'Sweetwater',
  image: 'https://picsum.photos/id/100/400/400',
  warrantyExpire: '2025-01-15',
  warrantyType: 'Manufacturer' as const,
  supportContact: 'support@sequential.com',
  specs: { Keys: '6', Type: 'Analog' },
  documents: [
    { name: 'Manual.pdf', type: 'manual' as const, url: '#' },
    { name: 'Receipt.pdf', type: 'receipt' as const, url: '#' },
  ],
  maintenanceHistory: [
    {
      id: 'm1',
      date: '2024-01-10',
      type: 'Calibration',
      notes: 'Full calibration done.',
    },
  ],
};

export const Default: Story = {
  args: {
    itemId: '1',
    onBack: () => {},
    initialItem: mockItem,
  },
};

export const Loading: Story = {
  name: 'Chargement',
  render: () => <EquipmentDetailViewSkeleton />,
};

export const NotFound: Story = {
  name: 'Non trouvé',
  args: {
    itemId: 'nonexistent',
    onBack: () => {},
    initialItem: null,
  },
};
