/* eslint-disable import/no-extraneous-dependencies */
import React from 'react';
import {
  Title,
  Description,
  Primary,
  Stories,
  PRIMARY_STORY,
  ArgsTable,
} from '@storybook/addon-docs/blocks';

import Archive from '.';
import { getListCardItem } from '~tests/factories/modules/card.factory';

export default {
  title: 'Theme/Organisms/Archive',
  component: Archive,
  argTypes: {
    module: {
      name: 'module',
      type: { name: 'object', required: false },
      defaultValue: '',
      description: 'The module data object',
      table: {
        type: { summary: 'object' },
        defaultValue: { summary: null },
      },
    },
  },
  parameters: {
    docs: {
      description: {
        component:
          'Displays a grid of cards either with a load more button or pagination. This component can be used with any cards types, for example with the Matrix-Theme article cards, operator cards, etc. In the archive module with pagination story we show the pagination with midpoints, but a different pagination component can be used, as needed. ',
      },
      page: () => (
        <>
          <Title />
          <Description />
          <Primary />
          <Stories />
          <ArgsTable story={PRIMARY_STORY} />
        </>
      ),
    },
  },
};

const ArchiveWithPagination = (args) => <Archive {...args} />;

export const WithPagination = ArchiveWithPagination.bind({});
WithPagination.story = {
  parameters: {
    docs: {
      storyDescription:
        'Please note pagination does not go to the next page in storybook. Therefore the archive with pagination is purely a visual representation.',
    },
  },
  args: {
    module: {
      module_title: 'Archive Module Title',
      items: getListCardItem(9).items,
      currentPage: 1,
      numOfPages: 10,
      rootPath: '/slots',
      pagination_type: 'numbered',
      mobile_num_of_columns: 1,
      tablet_num_of_columns: 3,
      desktop_num_of_columns: 3,
    },
    showTitle: true,
    page: {
      translations: {},
    },
  },
};

const ArchiveWithLoadMore = (args) => <Archive {...args} />;

export const WithLoadMore = ArchiveWithLoadMore.bind({});
WithLoadMore.args = {
  module: {
    module_title: 'Archive Module Title',
    items: getListCardItem(21).items,
    currentPage: 1,
    numOfPages: 10,
    rootPath: '/slots',
    pagination_type: 'load_more',
    mobile_num_of_columns: 1,
    tablet_num_of_columns: 3,
    desktop_num_of_columns: 3,
    num_of_items: 6,
  },
  page: {
    translations: {},
  },
};
