diff --git a/app/components/PublicRoute/__snapshots__/PublicRoute.test.js.snap b/app/components/PublicRoute/__snapshots__/PublicRoute.test.js.snap index c59367f..6b28353 100644 --- a/app/components/PublicRoute/__snapshots__/PublicRoute.test.js.snap +++ b/app/components/PublicRoute/__snapshots__/PublicRoute.test.js.snap @@ -36,13 +36,17 @@ exports[` renders Login if user is not authenticated 1`] = ` > Login - - or Create An Account - + + or Create An Account + +
renders Login if user is not authenticated 1`] = ` Login - - Forgot Password? - + + Forgot Password? + +
diff --git a/app/components/TextInput/README.md b/app/components/TextInput/README.md index a73e93e..03bcc97 100644 --- a/app/components/TextInput/README.md +++ b/app/components/TextInput/README.md @@ -1,5 +1,5 @@ -## TextInput +## undefined A control to input a single line of text, with optional suggestions. ## Usage diff --git a/app/components/TextInput/TextInput.js b/app/components/TextInput/TextInput.js index f1d2b6f..1d7ff1c 100644 --- a/app/components/TextInput/TextInput.js +++ b/app/components/TextInput/TextInput.js @@ -1,5 +1,5 @@ /* eslint-disable react/prop-types */ -import React from 'react' +import React, { forwardRef } from 'react' // Components import { TextInput as GrommetTextInput } from 'grommet' @@ -13,9 +13,9 @@ import { createWithDoc } from '../../utils/helpers' * TextInput * */ -const TextInput = ({ name, type, ...rest }) => ( - -) +const TextInput = forwardRef(({ name, type, ...rest }, ref) => ( + +)) export default createWithDoc({ envName: process.env.NODE_ENV, diff --git a/app/pages/Login/Login.js b/app/pages/Login/Login.js index 3babccf..5176447 100644 --- a/app/pages/Login/Login.js +++ b/app/pages/Login/Login.js @@ -1,7 +1,8 @@ /* @flow */ -import React, { useContext, useEffect, useState } from 'react' +import React, { useContext, useEffect, useRef, useState } from 'react' import { isEmail } from 'validator' import PropTypes from 'prop-types' +import { useHistory } from 'react-router-dom' // Components import { Box } from 'components/Box' @@ -10,28 +11,42 @@ import { Form, FormField } from 'components/Form' import { FormContainer } from 'components/FormContainer' import { Heading } from 'components/Heading' import { Message } from 'components/Message' -import { Link } from 'components/Link' import { LogoHeader } from 'components/LogoHeader' import { PasswordInput } from 'components/PasswordInput' +import { Text } from 'components/Text' import { TextInput } from 'components/TextInput' -// Utils and messages -import useFlashMessage from '../../hooks/FlashMessage' +// Service import { login } from '../../services/user.service' + +// Store import { UserStoreContext } from '../../stores/UserStore' +// Style +import { baseColors } from '../../utils/colors' + +// Utils +import useFlashMessage from '../../hooks/FlashMessage' + /** * * Login * */ const Login = ({ location }) => { + // Messages const { message: error, showMessage: showError } = useFlashMessage(null) const { message: redirectedMessage, showMessage: showRedirectedMessage } = useFlashMessage(null) + // Context + const history = useHistory() + const { setCurrentUser, setCurrentTokens } = useContext(UserStoreContext) + + // State const [loading, setLoading] = useState(false) - const { setCurrentUser, setCurrentTokens } = useContext(UserStoreContext) + // Ref + const emailRef = useRef() /** * Check if the user has been redirected to this page with a URL parameter @@ -56,7 +71,16 @@ const Login = ({ location }) => { Login - or Create An Account +