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 './changePasswordForm.scss';

const styles = classNames.bind(styleIdentifiers);

export interface StateProps {}

export interface DispatchProps {}

export interface OwnProps {
  onSubmit: Function;
}

export type ChangePasswordFormProps = StateProps & DispatchProps & OwnProps;

const ChangePasswordForm = (props: ChangePasswordFormProps) => {
  const { handleSubmit, submitting, valid } = props;

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

  return (
    <form className={styles('ChangePasswordForm')} onSubmit={handleSubmit}>
      <Field
        component={ProjectInput}
        seed="password"
        name="oldPassword"
        label="forms.settings.oldPassword"
        validate={required}
        placeholder="•••••••••"
      />
      <Field
        component={ProjectInput}
        seed="password"
        name="newPassword"
        label="forms.settings.newPassword"
        validate={required}
        placeholder="•••••••••"
      />
      <Field
        component={ProjectInput}
        seed="password"
        name="newPasswordConfirmation"
        label="forms.settings.confirmNewPassword"
        validate={required}
        placeholder="•••••••••"
      />
      <ProjectButton
        disabled={submitting || !valid}
        color="primary"
        label="forms.settings.changePassword"
        rounded
        type="submit"
      />
    </form>
  );
};

export default ChangePasswordForm;
