Skip to content
Snippets Groups Projects
Commit c77b43c5 authored by Jure's avatar Jure
Browse files

feat: improve Login page

parent c44cf859
No related branches found
No related tags found
No related merge requests found
test/
# Change Log
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [3.0.23](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@3.0.22...pubsweet-component-login@3.0.23) (2020-03-04)
**Note:** Version bump only for package pubsweet-component-login
## [3.0.22](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@3.0.21...pubsweet-component-login@3.0.22) (2020-02-28)
**Note:** Version bump only for package pubsweet-component-login
## [3.0.21](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@3.0.20...pubsweet-component-login@3.0.21) (2020-02-26)
**Note:** Version bump only for package pubsweet-component-login
## [3.0.20](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@3.0.19...pubsweet-component-login@3.0.20) (2020-01-29)
**Note:** Version bump only for package pubsweet-component-login
## [3.0.19](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@3.0.18...pubsweet-component-login@3.0.19) (2020-01-23)
**Note:** Version bump only for package pubsweet-component-login
## [3.0.18](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@3.0.17...pubsweet-component-login@3.0.18) (2019-12-11)
### Bug Fixes
* small styling fixes ([3c6a11f](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/3c6a11f0c558a9b6a433c9b122b8226133461bf0))
## [3.0.17](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@3.0.16...pubsweet-component-login@3.0.17) (2019-11-11)
**Note:** Version bump only for package pubsweet-component-login
## [3.0.16](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@3.0.15...pubsweet-component-login@3.0.16) (2019-09-11)
**Note:** Version bump only for package pubsweet-component-login
## [3.0.15](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@3.0.14...pubsweet-component-login@3.0.15) (2019-09-04)
**Note:** Version bump only for package pubsweet-component-login
## [3.0.14](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@3.0.13...pubsweet-component-login@3.0.14) (2019-08-30)
**Note:** Version bump only for package pubsweet-component-login
## [3.0.13](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@3.0.12...pubsweet-component-login@3.0.13) (2019-08-08)
**Note:** Version bump only for package pubsweet-component-login
## [3.0.12](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@3.0.11...pubsweet-component-login@3.0.12) (2019-08-05)
**Note:** Version bump only for package pubsweet-component-login
## [3.0.11](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@3.0.10...pubsweet-component-login@3.0.11) (2019-07-12)
**Note:** Version bump only for package pubsweet-component-login
## [3.0.10](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@3.0.9...pubsweet-component-login@3.0.10) (2019-07-09)
**Note:** Version bump only for package pubsweet-component-login
## [3.0.9](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@3.0.8...pubsweet-component-login@3.0.9) (2019-07-03)
**Note:** Version bump only for package pubsweet-component-login
## [3.0.8](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@3.0.7...pubsweet-component-login@3.0.8) (2019-06-28)
**Note:** Version bump only for package pubsweet-component-login
## [3.0.7](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@3.0.6...pubsweet-component-login@3.0.7) (2019-06-24)
**Note:** Version bump only for package pubsweet-component-login
## [3.0.6](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@3.0.5...pubsweet-component-login@3.0.6) (2019-06-21)
**Note:** Version bump only for package pubsweet-component-login
## [3.0.5](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@3.0.4...pubsweet-component-login@3.0.5) (2019-06-13)
**Note:** Version bump only for package pubsweet-component-login
## [3.0.4](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@3.0.3...pubsweet-component-login@3.0.4) (2019-06-12)
**Note:** Version bump only for package pubsweet-component-login
## [3.0.3](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@3.0.2...pubsweet-component-login@3.0.3) (2019-05-27)
**Note:** Version bump only for package pubsweet-component-login
## [3.0.2](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@3.0.1...pubsweet-component-login@3.0.2) (2019-04-25)
**Note:** Version bump only for package pubsweet-component-login
## [3.0.1](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@3.0.0...pubsweet-component-login@3.0.1) (2019-04-18)
**Note:** Version bump only for package pubsweet-component-login
# [3.0.0](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@2.1.1...pubsweet-component-login@3.0.0) (2019-04-09)
### Features
* **login:** move login code into src folder ([88c38fc](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/88c38fc))
### BREAKING CHANGES
* **login:** If you've required the Login component directly, e.g.
require('pubsweet-component-login/LoginContainer'), you have to change those requires to
require('pubsweet-component-login') and get Login (LoginContainer) from the export.
## [2.1.1](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@2.1.0...pubsweet-component-login@2.1.1) (2019-03-06)
**Note:** Version bump only for package pubsweet-component-login
# [2.1.0](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@2.0.2...pubsweet-component-login@2.1.0) (2019-03-05)
### Bug Fixes
* **depedencies:** add styled components ([47149c2](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/47149c2))
* **login:** add placeholder to fields ([b2431d4](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/b2431d4))
* **login:** delete unneeded files ([3fb140a](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/3fb140a))
* **redirect:** after login the user ([c7618da](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/c7618da))
* **test:** fix export of the Login component ([90df50a](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/90df50a))
* **test:** update login snapshot. ui updated ([7518d7a](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/7518d7a))
### Features
* **login:** add optional logo at the login screen ([debe63a](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/debe63a))
## [2.0.2](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@2.0.1...pubsweet-component-login@2.0.2) (2019-02-19)
**Note:** Version bump only for package pubsweet-component-login
## [2.0.1](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@2.0.0...pubsweet-component-login@2.0.1) (2019-02-19)
**Note:** Version bump only for package pubsweet-component-login
# [2.0.0](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@1.2.8...pubsweet-component-login@2.0.0) (2019-02-01)
### Code Refactoring
* temporarily remove unmigrated components ([32db6ad](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/32db6ad))
### Features
* remove redux ([4217850](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/4217850))
### BREAKING CHANGES
* A lot of unmigrated (not yet moved from REST/Redux to GraphQL/Apollo system) bits
have changed. There might be some breaking changes as a result. This is a big migration involving
big changes - if you encounter anything weird, please contact us on GitLab or on Mattermost.
* All components that rely on Redux's actions and reducers will cease to work in this
version. Migrating to GraphQL and Apollo on the client and server is advised.
## [1.2.8](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@1.2.7...pubsweet-component-login@1.2.8) (2019-01-16)
### Bug Fixes
* **graphql:** review components fixes ([8094d9e](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/8094d9e))
* **login:** error on integration test failed login ([f061e58](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/f061e58))
* **login:** redirect to the dashboard ([41a7cc9](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/41a7cc9))
* **login:** unneeded vars ([7610f94](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/7610f94))
* **test:** formbuilder ([93c55fd](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/93c55fd))
* **test:** login tests ([438ab2e](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/438ab2e))
* **test:** problems with eslint and test ([48f7fe2](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/48f7fe2))
## [1.2.7](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@1.2.6...pubsweet-component-login@1.2.7) (2019-01-14)
**Note:** Version bump only for package pubsweet-component-login
## [1.2.6](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@1.2.5...pubsweet-component-login@1.2.6) (2019-01-13)
**Note:** Version bump only for package pubsweet-component-login
## [1.2.5](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@1.2.4...pubsweet-component-login@1.2.5) (2019-01-09)
**Note:** Version bump only for package pubsweet-component-login
## [1.2.4](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@1.2.3...pubsweet-component-login@1.2.4) (2018-12-12)
**Note:** Version bump only for package pubsweet-component-login
## [1.2.3](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@1.2.2...pubsweet-component-login@1.2.3) (2018-12-04)
**Note:** Version bump only for package pubsweet-component-login
## [1.2.2](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@1.2.1...pubsweet-component-login@1.2.2) (2018-11-30)
**Note:** Version bump only for package pubsweet-component-login
## [1.2.1](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@1.2.0...pubsweet-component-login@1.2.1) (2018-11-29)
**Note:** Version bump only for package pubsweet-component-login
<a name="1.2.0"></a>
# [1.2.0](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@1.1.18...pubsweet-component-login@1.2.0) (2018-11-05)
### Features
* GraphQL Login component ([70df3de](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/70df3de))
* GraphQL Xpub submit component ([ba07060](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/ba07060))
<a name="1.1.18"></a>
## [1.1.18](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@1.1.17...pubsweet-component-login@1.1.18) (2018-10-08)
**Note:** Version bump only for package pubsweet-component-login
<a name="1.1.17"></a>
## [1.1.17](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@1.1.16...pubsweet-component-login@1.1.17) (2018-09-27)
**Note:** Version bump only for package pubsweet-component-login
<a name="1.1.16"></a>
## [1.1.16](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@1.1.15...pubsweet-component-login@1.1.16) (2018-09-19)
**Note:** Version bump only for package pubsweet-component-login
<a name="1.1.15"></a>
## [1.1.15](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@1.1.14...pubsweet-component-login@1.1.15) (2018-09-06)
**Note:** Version bump only for package pubsweet-component-login
<a name="1.1.14"></a>
## [1.1.14](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@1.1.13...pubsweet-component-login@1.1.14) (2018-09-04)
**Note:** Version bump only for package pubsweet-component-login
<a name="1.1.13"></a>
## [1.1.13](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@1.1.12...pubsweet-component-login@1.1.13) (2018-08-20)
**Note:** Version bump only for package pubsweet-component-login
<a name="1.1.12"></a>
## [1.1.12](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@1.1.11...pubsweet-component-login@1.1.12) (2018-08-17)
**Note:** Version bump only for package pubsweet-component-login
<a name="1.1.11"></a>
## [1.1.11](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@1.1.10...pubsweet-component-login@1.1.11) (2018-08-02)
**Note:** Version bump only for package pubsweet-component-login
<a name="1.1.10"></a>
## [1.1.10](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@1.1.9...pubsweet-component-login@1.1.10) (2018-07-27)
**Note:** Version bump only for package pubsweet-component-login
<a name="1.1.9"></a>
## [1.1.9](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@1.1.8...pubsweet-component-login@1.1.9) (2018-07-12)
**Note:** Version bump only for package pubsweet-component-login
<a name="1.1.8"></a>
## [1.1.8](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@1.1.7...pubsweet-component-login@1.1.8) (2018-07-09)
**Note:** Version bump only for package pubsweet-component-login
<a name="1.1.7"></a>
## [1.1.7](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@1.1.6...pubsweet-component-login@1.1.7) (2018-07-03)
**Note:** Version bump only for package pubsweet-component-login
<a name="1.1.6"></a>
## [1.1.6](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@1.1.5...pubsweet-component-login@1.1.6) (2018-07-02)
**Note:** Version bump only for package pubsweet-component-login
<a name="1.1.5"></a>
## [1.1.5](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@1.1.4...pubsweet-component-login@1.1.5) (2018-06-28)
**Note:** Version bump only for package pubsweet-component-login
<a name="1.1.4"></a>
## [1.1.4](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@1.1.3...pubsweet-component-login@1.1.4) (2018-06-28)
**Note:** Version bump only for package pubsweet-component-login
<a name="1.1.3"></a>
## [1.1.3](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@1.1.2...pubsweet-component-login@1.1.3) (2018-06-19)
### Bug Fixes
* **pubsweet-ui:** tests are failing ([0e57798](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/0e57798))
<a name="1.1.2"></a>
## [1.1.2](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@1.1.1...pubsweet-component-login@1.1.2) (2018-04-03)
**Note:** Version bump only for package pubsweet-component-login
<a name="1.1.1"></a>
## [1.1.1](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@1.1.0...pubsweet-component-login@1.1.1) (2018-03-15)
### Bug Fixes
* **login:** add missing recompose dependency ([a3b5a80](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/a3b5a80)), closes [#353](https://gitlab.coko.foundation/pubsweet/pubsweet/issues/353)
<a name="1.1.0"></a>
# [1.1.0](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@1.0.1...pubsweet-component-login@1.1.0) (2018-03-05)
### Bug Fixes
* **components:** login example ([6dfd66c](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/6dfd66c))
* **components:** login tests were failing after refactor ([62be047](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/62be047))
* **components:** signup and login error examples ([3f991ec](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/3f991ec))
### Features
* **elife-theme:** add elife theme ([e406e0d](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/e406e0d))
<a name="1.0.1"></a>
## [1.0.1](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@1.0.0...pubsweet-component-login@1.0.1) (2018-02-08)
### Bug Fixes
* **components:** update react-router-redux version to match client ([3d257ef](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/3d257ef))
<a name="1.0.0"></a>
# [1.0.0](https://gitlab.coko.foundation/pubsweet/pubsweet/compare/pubsweet-component-login@0.6.0...pubsweet-component-login@1.0.0) (2018-02-02)
### Features
* **client:** upgrade React to version 16 ([626cf59](https://gitlab.coko.foundation/pubsweet/pubsweet/commit/626cf59)), closes [#65](https://gitlab.coko.foundation/pubsweet/pubsweet/issues/65)
### BREAKING CHANGES
* **client:** Upgrade React to version 16
import React, { useState } from 'react'
import { Redirect } from 'react-router-dom'
import PropTypes from 'prop-types'
import { withFormik, Field } from 'formik'
import { isEmpty } from 'lodash'
import { withFormik } from 'formik'
import config from 'config'
import { override } from '@pubsweet/ui-toolkit'
import { useMutation } from '@apollo/react-hooks'
import {
CenteredColumn,
ErrorText,
H1,
Link,
Button,
TextField,
} from '@pubsweet/ui'
import { th, grid } from '@pubsweet/ui-toolkit'
import { CenteredColumn, H1, Button } from '@pubsweet/ui'
import styled from 'styled-components'
import { LOGIN_USER } from './graphql/mutations'
import { Container, Content, Section } from '../../shared'
const getNextUrl = () => {
const url = new URL(window.location.href)
......@@ -59,39 +48,50 @@ const getToken = props => {
return null
}
const Logo = styled.div`
${override('Login.Logo')};
`
Logo.displayName = 'Logo'
const LoginLink = styled.a`
display: inline-block;
background: ${th('colorPrimary')};
border-radius: ${th('borderRadius')};
line-height: ${grid(4)};
color: ${th('colorTextReverse')};
const FormContainer = styled.div`
${override('Login.FormContainer')};
padding: ${grid(1)} ${grid(2)};
margin-bottom: ${grid(1)};
margin-top: ${grid(3)};
`
const UsernameInput = props => (
<TextField label="Username" placeholder="Username" {...props.field} />
)
const CenteredSection = styled(Section)`
text-align: center;
`
const PasswordInput = props => (
<TextField
label="Password"
placeholder="Password"
{...props.field}
type="password"
/>
const ORCIDIcon = ({className}) => (
<span className={className}>
<svg viewBox="0 0 256 256">
<path
d="M256,128c0,70.7-57.3,128-128,128C57.3,256,0,198.7,0,128C0,57.3,57.3,0,128,0C198.7,0,256,57.3,256,128z"
fill="#A6CE39"
/>
<g>
<path d="M86.3,186.2H70.9V79.1h15.4v48.4V186.2z" fill="#FFFFFF" />
<path
d="M108.9,79.1h41.6c39.6,0,57,28.3,57,53.6c0,27.5-21.5,53.6-56.8,53.6h-41.8V79.1z M124.3,172.4h24.5 c34.9,0,42.9-26.5,42.9-39.7c0-21.5-13.7-39.7-43.7-39.7h-23.7V172.4z"
fill="#FFFFFF"
/>
<path
d="M88.7,56.8c0,5.5-4.5,10.1-10.1,10.1c-5.6,0-10.1-4.6-10.1-10.1c0-5.6,4.5-10.1,10.1-10.1 C84.2,46.7,88.7,51.3,88.7,56.8z"
fill="#FFFFFF"
/>
</g>
</svg>
</span>
)
const Login = ({
errors,
logo = null,
signup = true,
passwordReset = true,
redirectLink,
handleSubmit,
orcid,
token,
...props
}) => {
const StyledORCIDIcon = styled(ORCIDIcon)`
svg {
height: 1rem;
}
`
const Login = ({ logo = null, redirectLink, orcid, token, ...props }) => {
if (token) {
window.localStorage.setItem('token', token)
return <Redirect to={redirectLink} />
......@@ -100,52 +100,25 @@ const Login = ({
return redirectLink ? (
<Redirect to={redirectLink} />
) : (
<CenteredColumn small>
{logo && (
<Logo>
<img alt="pubsweet-logo" src={`${logo}`} />
</Logo>
)}
<FormContainer>
<H1>Login to SimpleJ</H1>
{!isEmpty(errors) && <ErrorText>{errors}</ErrorText>}
<form onSubmit={handleSubmit}>
{/* <Field component={UsernameInput} name="username" />
<Field component={PasswordInput} name="password" /> */}
<a href="/auth/orcid">
<Button primary>
Login with ORCID
</Button>
</a>
</form>
{/* {signup && (
<p>
Don&apos;t have an account? <Link to="/signup">Sign up</Link>
</p>
)} */}
{/* {passwordReset && (
<p>
Forgot your password?{' '}
<Link to="/password-reset">Reset password</Link>
</p>
)} */}
</FormContainer>
</CenteredColumn>
<Container>
<H1>Login to SimpleJ</H1>
<Content>
<CenteredSection>
SimpleJ uses ORCID <StyledORCIDIcon /> to identify authors and staff. Login with your
ORCID account below or{' '}
<a href="https://orcid.org/signin">register at the ORCID website.</a>
<LoginLink href="/auth/orcid" primary>
Login with ORCID
</LoginLink>
</CenteredSection>
</Content>
</Container>
)
}
Login.propTypes = {
error: PropTypes.string,
actions: PropTypes.object,
location: PropTypes.object,
signup: PropTypes.bool,
passwordReset: PropTypes.bool,
logo: PropTypes.string,
}
const EnhancedFormik = withFormik({
initialValues: {
username: '',
......@@ -173,10 +146,8 @@ export default props => {
// Also set the redirect link upon successful login (via handleSubmit)
const onLoggedIn = () => setRedirectLink(getNextUrl())
const [loginUser] = useMutation(LOGIN_USER)
return (
<EnhancedFormik
loginUser={loginUser}
onLoggedIn={onLoggedIn}
orcid={orcid}
redirectLink={redirectLink}
......
A login form
```js
const { withFormik } = require('formik')
const LoginForm = withFormik({
initialValues: {
username: '',
password: '',
},
mapPropsToValues: props => ({
username: props.username,
password: props.password,
}),
displayName: 'login',
handleSubmit: val => console.log(val),
})(Login)
;<LoginForm />
```
Which can have an error message:
```js
const { withFormik } = require('formik')
const LoginForm = withFormik({
initialValues: {
username: '',
password: '',
},
mapPropsToValues: props => ({
username: props.username,
password: props.password,
}),
displayName: 'login',
handleSubmit: (values, { setErrors }) =>
setErrors('Wrong username or password.'),
})(Login)
;<LoginForm />
```
import gql from 'graphql-tag'
export const LOGIN_USER = gql`
mutation($input: LoginUserInput) {
loginUser(input: $input) {
token
}
}
`
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment