import PropTypes from 'prop-types'; import React from 'react'; import { domOnlyProps } from '../../../utils/reduxFormUtils'; import Button from '../../../common/Button'; function AccountForm(props) { const { fields: { username, email, currentPassword, newPassword }, user, handleSubmit, initiateVerification, submitting, invalid, pristine, } = props; const handleInitiateVerification = (evt) => { evt.preventDefault(); initiateVerification(); }; return (

{email.touched && email.error && ( {email.error} )}

{user.verified !== 'verified' && (

Unconfirmed. {user.emailVerificationInitiate === true ? ( {' '} Confirmation sent, check your email. ) : ( )}

)}

{username.touched && username.error && ( {username.error} )}

{currentPassword.touched && currentPassword.error && ( {currentPassword.error} )}

{newPassword.touched && newPassword.error && ( {newPassword.error} )}

); } AccountForm.propTypes = { fields: PropTypes.shape({ username: PropTypes.object.isRequired, // eslint-disable-line email: PropTypes.object.isRequired, // eslint-disable-line currentPassword: PropTypes.object.isRequired, // eslint-disable-line newPassword: PropTypes.object.isRequired, // eslint-disable-line }).isRequired, user: PropTypes.shape({ verified: PropTypes.number.isRequired, emailVerificationInitiate: PropTypes.bool.isRequired, }).isRequired, handleSubmit: PropTypes.func.isRequired, initiateVerification: PropTypes.func.isRequired, updateSettings: PropTypes.func.isRequired, submitting: PropTypes.bool, invalid: PropTypes.bool, pristine: PropTypes.bool, }; AccountForm.defaultProps = { submitting: false, pristine: true, invalid: false, }; export default AccountForm;