import type { Meta, StoryObj } from '@storybook/react-vite';
import { EventGridSkeleton } from '@/components/events/event-grid/event-grid.skeleton';
import { EventGridView } from '@/components/events/event-grid/event-grid.view';
import { Button } from '@/components/ui/button';
import { Skeleton as UiSkeleton } from '@/components/ui/skeleton';

const meta = {
  title: 'Events/EventGrid',
  component: EventGridView,
} satisfies Meta<typeof EventGridView>;

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

export const Primary: Story = {
  args: {
    events: [
      {
        eventId: '1',
        requireKyc: true,
        isJoined: false,
        type: 'official',
        coverImage: 'https://github.com/NixOS/nixos-artwork/blob/master/wallpapers/nix-wallpaper-watersplash.png?raw=true',
        eventName: 'Nix CN Conference 26.05',
        description: 'Event Description',
        startTime: new Date('2026-06-13T04:00:00.000Z'),
        endTime: new Date('2026-06-14T04:00:00.000Z'),
      },
      {
        eventId: '2',
        requireKyc: true,
        isJoined: false,
        type: 'official',
        coverImage: 'https://github.com/NixOS/nixos-artwork/blob/master/wallpapers/nix-wallpaper-moonscape.png?raw=true',
        eventName: 'Nix CN Conference 26.05',
        description: 'Event Description',
        startTime: new Date('2026-06-13T04:00:00.000Z'),
        endTime: new Date('2026-06-14T04:00:00.000Z'),
      },
      {
        eventId: '3',
        requireKyc: true,
        isJoined: false,
        type: 'official',
        coverImage: 'https://github.com/NixOS/nixos-artwork/blob/master/wallpapers/nix-wallpaper-nineish-catppuccin-latte.png?raw=true',
        eventName: 'Nix CN Conference 26.05',
        description: 'Event Description',
        startTime: new Date('2026-06-13T04:00:00.000Z'),
        endTime: new Date('2026-06-14T04:00:00.000Z'),
      },
      {
        eventId: '4',
        requireKyc: true,
        isJoined: false,
        type: 'official',
        coverImage: 'https://github.com/NixOS/nixos-artwork/blob/master/wallpapers/nixos-wallpaper-catppuccin-macchiato.png?raw=true',
        eventName: 'Nix CN Conference 26.05',
        description: 'Event Description',
        startTime: new Date('2026-06-13T04:00:00.000Z'),
        endTime: new Date('2026-06-14T04:00:00.000Z'),
      },
    ],
    footer: () => <Button className="w-full">加入活动</Button>,
  },
};

export const Empty: Story = {
  decorators: [Story => <div className="h-screen"><Story /></div>],
  args: {
    events: [],
    footer: () => <Button className="w-full">加入活动</Button>,
  },
  parameters: {
    layout: 'fullscreen',
  },
};

export const Loading: Story = {
  render: () => <EventGridSkeleton />,
  args: {
    events: [],
    footer: () => <UiSkeleton className="w-full" />,
  },
};
