import React from 'react';
import { Field } from 'react-final-form';
import classNames from 'classnames/bind';

import { required, email, composeValidators } from 'store/utils/validation';
import ProjectInput from 'components/formItems/ProjectInput';
import ProjectButton from 'components/items/ProjectButton';
import styleIdentifiers from './appResetPasswordForm.scss';

const styles = classNames.bind(styleIdentifiers);

export interface StateProps {}

export interface DispatchProps {}

export interface OwnProps {
  onSubmit: Function;
}

export type AppResetPasswordFormProps = StateProps & DispatchProps & OwnProps;

const AppResetPasswordForm = (props: AppResetPasswordFormProps) => {
  const { handleSubmit, submitting, valid, customClassName } = props;
  return (
    <form className={styles('AppResetPasswordForm', customClassName)} onSubmit={handleSubmit}>
      <Field
        component={ProjectInput}
        name="email"
        type="email"
        placeholder="example@mail.com"
        label="forms.resetPassword.email"
        validate={composeValidators(required, email)}
      />
      <ProjectButton
        disabled={submitting || !valid}
        color="primary"
        label="forms.resetPassword.send"
        rounded
        type="submit"
      />
    </form>
  );
};

export default AppResetPasswordForm;
