import React from 'react';
// eslint-disable-next-line import/no-extraneous-dependencies
import {
  Title,
  Description,
  Primary,
  PRIMARY_STORY,
  ArgsTable,
} from '@storybook/addon-docs/blocks';
import { siteSchema } from 'gatsby-core-theme/tests/factories/modules/site-schema.factory';
import getPageList from 'gatsby-core-theme/tests/factories/pages/page.factory';
import ContactForm from '.';

const relationType = 'default';
const market = 'ie_en';
const samplePages = {
  [market]: {
    [relationType]: getPageList({
      template: relationType,
      count: 3,
      relation: null,
      relation_id: 5,
      market,
      siteSchema: { ...siteSchema },
    }),
  },
};

// const page = {};
// page.siteSchema = { ...siteSchema };

export default {
  title: 'Theme/Modules/Template Blocks/Contact us page/Contact Form',
  component: ContactForm,
  argTypes: {
    page: {
      name: 'page',
      type: { name: 'object', required: true },
      defaultValue: '',
      description: 'page object',
      siteSchema: {
        type: { summary: 'object' },
        defaultValue: { summary: '' },
      },
    },
    submitUrl: {
      name: 'submitUrl',
      type: { name: 'string', required: false },
      defaultValue: '',
      description: 'submit URL',
    },
    successMessage: {
      name: 'successMessage',
      type: { name: 'string', required: false },
      defaultValue: 'Message sent successfully.',
      description: 'sent message text',
    },
    failMessage: {
      name: 'failMessage',
      type: { name: 'string', required: false },
      defaultValue: 'Message not sent.',
      description: 'fail message text',
    },
    validationMessage: {
      name: 'validationMessage',
      type: { name: 'string', required: false },
      defaultValue: 'Fill all the required fields.',
      description: 'sent message info',
    },
    buttonLabel: {
      name: 'buttonLabel',
      type: { name: 'string', required: false },
      defaultValue: 'Send Message',
      description: 'Send button text',
    },
    showFollowUs: {
      name: 'showFollowUs',
      type: { name: 'boolean', required: false },
      defaultValue: true,
      description: 'Show Follow us social media icons & links from Site Scheme',
    },
    showEmail: {
      name: 'showEmail',
      type: { name: 'boolean', required: false },
      defaultValue: true,
      description: 'Show email address only',
    },
    showButtonIcon: {
      name: 'showButtonIcon',
      type: { name: 'boolean', required: false },
      defaultValue: true,
      description: 'Show/hide button icon',
    },
    showLabels: {
      name: 'showLabels',
      type: { name: 'boolean', required: false },
      defaultValue: true,
      description: 'Show/hide form field lables',
    },
    showHeading: {
      name: 'showHeading',
      type: { name: 'boolean', required: false },
      defaultValue: true,
      description: 'Show/hide intro title of page',
    },
    showDescription: {
      name: 'showDescription',
      type: { name: 'boolean', required: false },
      defaultValue: true,
      description: 'Show/hide intro description of page',
    },
  },
  parameters: {
    docs: {
      description: {
        component: 'A component that displays authors cards',
      },
      page: () => (
        <>
          <Title />
          <Description />
          <Primary />
          <ArgsTable story={PRIMARY_STORY} />
        </>
      ),
    },
  },
};

const Template = (args) => <ContactForm {...args} />;
export const Default = Template.bind({});
Default.args = {
  page: samplePages[market][relationType][0],
};
