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 { contactUsForm } from '../../../constants/forms';

import Form from '.';

export default {
  title: 'Theme/Organisms/Form',
  component: Form,
  argTypes: {
    formOptions: {
      name: 'formOptions',
      type: { name: 'object', required: true },
      defaultValue: '',
      description: 'Form Options object from contstants',
      siteSchema: {
        type: { summary: 'object' },
        defaultValue: { summary: '' },
      },
    },
    successMessage: {
      name: 'successMessage',
      type: { name: 'string', required: false },
      defaultValue: 'Form has sent successfully',
      description: `This text message will show when the form is submitted successfully.`,
      table: {
        type: { summary: 'string' },
        defaultValue: { summary: 'Form has sent successfully' },
      },
    },
    failMessage: {
      name: 'failMessage',
      type: { name: 'string', required: false },
      defaultValue: 'Form has not sent, Got some error',
      description: `This text message will show when  submitting the form is failed.`,
      table: {
        type: { summary: 'string' },
        defaultValue: { summary: 'Form has not sent, Got some error' },
      },
    },
    validationMessage: {
      name: 'validationMessage',
      type: { name: 'string', required: false },
      defaultValue: 'Fill all the required fields',
      description: `This text message will show when the user didnot fill all required fields.`,
      table: {
        type: { summary: 'string' },
        defaultValue: { summary: 'Fill all the required fields' },
      },
    },
    submitUrl: {
      name: 'submitUrl',
      type: { name: 'string', required: true },
      defaultValue: '',
      description: `The form data will send to this URL on submit.`,
      table: {
        type: { summary: 'string' },
        defaultValue: { summary: '' },
      },
    },
    hasButton: {
      name: 'hasButton',
      type: { name: 'boolean', required: false },
      defaultValue: true,
      description: 'From has or has not a submit button.',
      table: {
        type: { summary: 'boolean' },
        defaultValue: { summary: true },
      },
    },
    buttonLabel: {
      name: 'buttonLabel',
      type: { name: 'string', required: false },
      defaultValue: 'Submit',
      description: `The submit button's text.`,
      table: {
        type: { summary: 'string' },
        defaultValue: { summary: 'Submit' },
      },
    },
    disabled: {
      name: 'disabled',
      type: { name: 'boolean', required: false },
      defaultValue: true,
      description: 'Form disabled',
      table: {
        type: { summary: 'boolean' },
        defaultValue: { summary: true },
      },
    },
    showLabels: {
      name: 'showLabels',
      type: { name: 'boolean', required: false },
      defaultValue: true,
      description: 'Show field lables or hide',
      table: {
        type: { summary: 'boolean' },
        defaultValue: { summary: true },
      },
    },
  },
  parameters: {
    docs: {
      description: {
        component: 'Generates a Contact-us or Newsletter from.',
      },
      page: () => (
        <>
          <Title />
          <Description />
          <Primary />
          <ArgsTable story={PRIMARY_STORY} />
        </>
      ),
    },
  },
};

const Template = (args) => <Form {...args} />;

export const Default = Template.bind({});
Default.args = {
  formOptions: contactUsForm.ie_en,
};
