From b5c32e552b35db85c3773a25c842b7395934a014 Mon Sep 17 00:00:00 2001
From: Anca Ursachi <anca.ursachi@thinslices.com>
Date: Mon, 3 Dec 2018 14:24:35 +0200
Subject: [PATCH] docs(PasswordConfirmation.md): Make the documentation for the
 passwordComfirmation component.

---
 .../src/PasswordConfirmation.js               | 31 ++++++++++++++++++-
 .../src/PasswordConfirmation.md               | 19 +++++++++---
 .../src/components/SignUp/SignUpStep1.js      |  3 +-
 3 files changed, 47 insertions(+), 6 deletions(-)

diff --git a/packages/component-faraday-ui/src/PasswordConfirmation.js b/packages/component-faraday-ui/src/PasswordConfirmation.js
index 9bd7fcbd7..a6aa981d2 100644
--- a/packages/component-faraday-ui/src/PasswordConfirmation.js
+++ b/packages/component-faraday-ui/src/PasswordConfirmation.js
@@ -1,4 +1,5 @@
 import React, { Fragment } from 'react'
+import PropTypes from 'prop-types'
 import { required } from 'xpub-validators'
 import { connect } from 'react-redux'
 import { getFormValues } from 'redux-form'
@@ -24,7 +25,7 @@ const PasswordConfirmation = ({
   minLength,
   atLeastOneDigit,
   atLeastOneUppercase,
-  submitFailed = false,
+  submitFailed,
   atLeastOneLowerrcase,
   atLeastOnePunctuation,
 }) => (
@@ -93,6 +94,34 @@ const PasswordConfirmation = ({
     </Row>
   </Fragment>
 )
+PasswordConfirmation.propTypes = {
+  /** Name of the redux form. */
+  formName: PropTypes.string,
+  /** Label name for password input */
+  formLabel: PropTypes.string,
+  /** If the password requirements are not fulfilled it will return true. */
+  submitFailed: PropTypes.bool,
+  /** If the password's length is greater or equal than the minimum value, it will return true. */
+  minLength: PropTypes.func,
+  /** If the password has at least one digit it will return true. */
+  atLeastOneDigit: PropTypes.func,
+  /** If the password has at least one uppercase it will return true. */
+  atLeastOneUppercase: PropTypes.func,
+  /** If the password has at least one lowercase it will return true. */
+  atLeastOneLowerrcase: PropTypes.func,
+  /** If the password has at least one punctuation it will return true. */
+  atLeastOnePunctuation: PropTypes.func,
+}
+PasswordConfirmation.defaultProps = {
+  formName: undefined,
+  formLabel: undefined,
+  submitFailed: false,
+  minLength: undefined,
+  atLeastOneDigit: undefined,
+  atLeastOneUppercase: undefined,
+  atLeastOneLowerrcase: undefined,
+  atLeastOnePunctuation: undefined,
+}
 
 export default compose(
   connect((state, props) => ({
diff --git a/packages/component-faraday-ui/src/PasswordConfirmation.md b/packages/component-faraday-ui/src/PasswordConfirmation.md
index ddfe53a6c..88bb5be46 100644
--- a/packages/component-faraday-ui/src/PasswordConfirmation.md
+++ b/packages/component-faraday-ui/src/PasswordConfirmation.md
@@ -1,5 +1,16 @@
 ```js
-<div>
-<PasswordConfirmation/>
-</div>
-```
\ No newline at end of file
+const React = require('react')
+const reduxForm = require('redux-form').reduxForm;
+
+const PasswordField = () => (
+  <PasswordConfirmation formLabel="Password" formName="signUpInvitation" />
+)
+
+const Form = reduxForm({
+  form: 'signUpInvitation',
+  destroyOnUnmount: false,
+  forceUnregisterOnUnmount: true,
+})(PasswordField);
+
+<Form />
+```
diff --git a/packages/components-faraday/src/components/SignUp/SignUpStep1.js b/packages/components-faraday/src/components/SignUp/SignUpStep1.js
index ffbc29dfa..a8b701635 100644
--- a/packages/components-faraday/src/components/SignUp/SignUpStep1.js
+++ b/packages/components-faraday/src/components/SignUp/SignUpStep1.js
@@ -10,7 +10,8 @@ import {
   PasswordConfirmation,
 } from 'pubsweet-component-faraday-ui'
 
-import { passwordValidator, emailValidator } from '../utils'
+import { emailValidator } from '../utils'
+import { passwordValidator } from '../../../../component-faraday-ui/src/Utils'
 
 const EmailField = input => <TextField {...input} type="email" />
 
-- 
GitLab