import { type Meta, type StoryObj } from '@storybook/react-vite';

import Post from './Post';

const url = 'https://i.imgur.com/bLIqWdp.jpeg';

const meta: Meta<typeof Post> = {
  component: Post,
  title: 'Composed Components/Posts/Post',
  tags: ['autodocs'],
  args: {
    fullName: 'Juane Algebra',
    body: 'Celebrando el Karaoke Pizza Party\nGracias a todos los quienes disfrutaron y participaron de esta actividad."Karaoke Pizza Party" es una dinámica empresarial que combina música y comida para fomentar el trabajo en equipo. Los participantes disfrutan compartiendo y degustando pizzas mientras cantan juntos en un ambiente relajado y divertido. Ideal para fortalecer relaciones y mejorar la comunicación.',
    publicationDatetime: '2022-01-01T12:00:00Z',
    media: [],
  },
  argTypes: {
    publicationDatetime: { control: 'date' },
  },
};

export default meta;

type Story = StoryObj<typeof Post>;

export const Default: Story = {
  args: {},
};

export const ActionablePost: Story = {
  args: {
    actions: {
      onEdit: () => alert('Edit'),
      onDelete: () => alert('Delete'),
    },
  },
};

const attachment = {
  url,
  type: 'IMAGE',
  name: 'image.jpg',
  bytes: 100000,
  size: '10 KB',
};

const longNameAttachment = {
  url,
  type: 'IMAGE',
  name: 'really_looooonggggggg_naaaaaaaaaammeeeeeeeeeeee.jpg',
  bytes: 100000,
  size: '10000000000000000000 KB',
};

export const PostWithMedia: Story = {
  args: {
    media: [
      { attachment, id: '1' },
      { attachment, id: '2' },
    ],
  },
};

export const PostWithFiles: Story = {
  args: {
    files: [
      { attachment: longNameAttachment, id: 1 },
      { attachment, id: 2 },
      { attachment, id: 3 },
      { attachment, id: 4 },
      { attachment, id: 5 },
      { attachment, id: 6 },
      { attachment, id: 7 },
      { attachment, id: 8 },
      { attachment: longNameAttachment, id: 9 },
    ],
  },
};

export const PostWithFilesAndMedia: Story = {
  args: {
    files: [{ attachment, id: '2' }],
    media: [{ attachment, id: '2' }],
  },
};

export const PostWithVideo: Story = {
  args: {
    media: [
      {
        id: 1,
        attachment: {
          bytes: 1,
          name: 'example_video.mp4',
          size: '13.03 MB',
          type: 'VIDEO',
          url: 'https://www.w3schools.com/html/mov_bbb.mp4',
        },
      },
      {
        id: 2,
        attachment: {
          bytes: 2,
          name: 'example_video_2.mp4',
          size: '13.03 MB',
          type: 'VIDEO',
          url: 'https://www.w3schools.com/html/mov_bbb.mp4',
        },
      },
    ],
  },
};
