import React from 'react';
import { Field } from 'react-final-form';

// Redux part
import { useSelector, useDispatch } from 'react-redux';
import { StoreState } from 'store/rootReducer';

// Import actions here

import classNames from 'classnames/bind';
import Input from 'components/formItems/Input';
import Button from 'components/items/Button';
import ProjectInput from 'components/formItems/ProjectInput';
import ProjectButton from 'components/items/ProjectButton';
import { required, email, composeValidators } from 'store/utils/validation';
import styleIdentifiers from './moreInfoCheckoutForm.scss';

const styles = classNames.bind(styleIdentifiers);

export interface StateProps {}

export interface DispatchProps {}

export interface OwnProps {
  onSubmit: Function;
}

export type MoreInfoCheckoutFormProps = StateProps & DispatchProps & OwnProps;

const MoreInfoCheckoutForm = (props: MoreInfoCheckoutFormProps) => {
  const { handleSubmit, relativeButton, button, submitting, valid, customClassName } = props;

  // mapStateToProps
  const content = useSelector((state: StoreState) => state.content.raw);

  return (
    <form className={styles('MoreInfoCheckoutForm', customClassName)} onSubmit={handleSubmit}>
      <Field
        component={ProjectInput}
        name="message"
        type="string"
        seed="textarea"
        label="forms.checkout.moreInfo.furtherInfo"
        placeholder="forms.checkout.moreInfo.placeholder"
        fieldWrapperClassName={styles('custom-field-wrapper')}
      />
      <ProjectButton
        relative={relativeButton}
        disabled={submitting || !valid}
        label={button || 'forms.checkout.moreInfo.validate'}
        type="submit"
        color="primary"
      />
    </form>
  );
};

export default MoreInfoCheckoutForm;
