diff --git a/packages/components-faraday/src/components/Login/LoginPage.js b/packages/components-faraday/src/components/Login/LoginPage.js new file mode 100644 index 0000000000000000000000000000000000000000..6ea37a256aa262136cdfef1e72b8cb04cbfeaa1a --- /dev/null +++ b/packages/components-faraday/src/components/Login/LoginPage.js @@ -0,0 +1,17 @@ +import Login from 'pubsweet-component-login/LoginContainer' +import { connect } from 'react-redux' +import { withProps, lifecycle, compose } from 'recompose' +import { actions } from 'pubsweet-client' + +const LoginPage = compose( + connect(null, { logoutUser: actions.logoutUser }), + withProps({ passwordReset: true }), + lifecycle({ + componentDidMount() { + const { logoutUser } = this.props + logoutUser() + }, + }), +)(Login) + +export default LoginPage diff --git a/packages/components-faraday/src/components/MakeRecommendation/StepTwo.js b/packages/components-faraday/src/components/MakeRecommendation/StepTwo.js index 7081d58f04ce2e3aa7ecc3ebce86a92aa99ed396..42950b27907076fd250e664ec9e93b9827566aef 100644 --- a/packages/components-faraday/src/components/MakeRecommendation/StepTwo.js +++ b/packages/components-faraday/src/components/MakeRecommendation/StepTwo.js @@ -18,7 +18,7 @@ import { utils } from './' import { FormItems } from '../UIComponents' const { - Row, + Row: FormRow, Err, Label, Title, @@ -212,4 +212,9 @@ const CustomRowItem = RowItem.extend` justify-content: flex-end; } ` +const Row = FormRow.extend` + div[role='alert'] { + margin-top: 0; + } +` // #endregion diff --git a/packages/components-faraday/src/components/SignUp/AuthorSignup.js b/packages/components-faraday/src/components/SignUp/AuthorSignup.js deleted file mode 100644 index 40f08b2fa2a95ca0c300d26a7ede8934f607f710..0000000000000000000000000000000000000000 --- a/packages/components-faraday/src/components/SignUp/AuthorSignup.js +++ /dev/null @@ -1,197 +0,0 @@ -import React, { Fragment } from 'react' -import { reduxForm } from 'redux-form' -import { th } from '@pubsweet/ui-toolkit' -import { required } from 'xpub-validators' -import { compose, withState } from 'recompose' -import styled, { css } from 'styled-components' -import { Icon, Button, TextField, ValidatedField } from '@pubsweet/ui' - -import { FormItems } from '../UIComponents' - -const { Row, RowItem, Label, RootContainer, FormContainer } = FormItems - -const Step1 = ({ handleSubmit }) => ( - <CustomFormContainer onSubmit={handleSubmit}> - <Fragment> - <CustomRow noMargin> - <CustomRowItem vertical> - <Label>Email</Label> - <ValidatedField - component={TextField} - name="email" - validate={[required]} - /> - </CustomRowItem> - </CustomRow> - <CustomRow> - <CustomRowItem vertical> - <Label>Password</Label> - <ValidatedField - component={TextField} - name="password" - validate={[required]} - /> - </CustomRowItem> - </CustomRow> - <CustomRow> - <CustomRowItem vertical> - <Label>Confirm password</Label> - <ValidatedField - component={TextField} - name="confirmPassword" - validate={[required]} - /> - </CustomRowItem> - </CustomRow> - </Fragment> - <Button primary type="submit"> - Next - </Button> - </CustomFormContainer> -) - -const AuthorSignupStep1 = reduxForm({ - form: 'authorSignup', - destroyOnUnmount: false, - enableReinitialize: true, - forceUnregisterOnUnmount: true, -})(Step1) - -const Step2 = ({ handleSubmit }) => ( - <CustomFormContainer onSubmit={handleSubmit}> - <Fragment> - <CustomRow noMargin> - <CustomRowItem vertical> - <Label>First name</Label> - <ValidatedField - component={TextField} - name="firstName" - validate={[required]} - /> - </CustomRowItem> - </CustomRow> - <CustomRow noMargin> - <CustomRowItem vertical> - <Label>Last name</Label> - <ValidatedField - component={TextField} - name="lastName" - validate={[required]} - /> - </CustomRowItem> - </CustomRow> - <CustomRow noMargin> - <CustomRowItem vertical> - <Label>Affiliation</Label> - <ValidatedField - component={TextField} - name="affiliation" - validate={[required]} - /> - </CustomRowItem> - </CustomRow> - <CustomRow noMargin> - <CustomRowItem vertical> - <Label>Title</Label> - <ValidatedField - component={TextField} - name="title" - validate={[required]} - /> - </CustomRowItem> - </CustomRow> - </Fragment> - <Button primary type="submit"> - Submit - </Button> - </CustomFormContainer> -) - -const AuthorSignupStep2 = reduxForm({ - form: 'authorSignup', - destroyOnUnmount: false, - forceUnregisterOnUnmount: true, - onSubmit: null, -})(Step2) - -const AuthorWizard = ({ step, changeStep, history }) => ( - <CustomRootContainer> - <IconButton onClick={history.goBack}> - <Icon primary size={3}> - x - </Icon> - </IconButton> - <Title>Author Signup</Title> - {step === 0 && <AuthorSignupStep1 onSubmit={() => changeStep(1)} />} - {step === 1 && <AuthorSignupStep2 />} - </CustomRootContainer> -) - -export default compose(withState('step', 'changeStep', 0))(AuthorWizard) - -// #region styled-components -const verticalPadding = css` - padding: ${th('subGridUnit')} 0; -` - -const CustomRow = Row.extend` - div[role='alert'] { - margin-top: 0; - } -` - -const CustomRowItem = RowItem.extend` - & > div { - flex: 1; - - & > div { - max-width: 400px; - width: 400px; - } - } -` - -const CustomRootContainer = RootContainer.extend` - align-items: center; - border: ${th('borderDefault')}; - position: relative; -` - -const CustomFormContainer = FormContainer.extend` - align-items: center; - display: flex; - flex-direction: column; - justify-content: flex-start; -` - -const Title = styled.span` - font-family: ${th('fontHeading')}; - font-size: ${th('fontSizeHeading5')}; - ${verticalPadding}; -` - -const IconButton = styled.button` - align-items: center; - background-color: ${th('backgroundColorReverse')}; - border: none; - color: ${th('colorPrimary')}; - cursor: ${({ hide }) => (hide ? 'auto' : 'pointer')}; - display: flex; - font-family: ${th('fontInterface')}; - font-size: ${th('fontSizeBaseSmall')}; - opacity: ${({ hide }) => (hide ? 0 : 1)}; - text-align: left; - - position: absolute; - top: ${th('subGridUnit')}; - right: ${th('subGridUnit')}; - - &:active, - &:focus { - outline: none; - } - &:hover { - opacity: 0.7; - } -` -// #endregion diff --git a/packages/components-faraday/src/components/SignUp/index.js b/packages/components-faraday/src/components/SignUp/index.js index d06b74c2b90e4e13790dc904c906288b50a4fe29..30bc2b64d1e031c948877bcc66e9831379833aa2 100644 --- a/packages/components-faraday/src/components/SignUp/index.js +++ b/packages/components-faraday/src/components/SignUp/index.js @@ -1,4 +1,3 @@ -export { default as AuthorSignup } from './AuthorSignup' export { default as ConfirmAccount } from './ConfirmAccount' export { default as ReviewerSignUp } from './ReviewerSignUp' export { default as ReviewerDecline } from './ReviewerDecline' diff --git a/packages/components-faraday/src/components/SignUp/utils.js b/packages/components-faraday/src/components/SignUp/utils.js index a46f99096ef2210e92ffa5c292846780009635da..c55e75faa4f33a292a68d855432b19b65d602598 100644 --- a/packages/components-faraday/src/components/SignUp/utils.js +++ b/packages/components-faraday/src/components/SignUp/utils.js @@ -34,7 +34,7 @@ export const parseSearchParams = url => { export const login = (dispatch, values, history) => dispatch(loginUser(values)) .then(() => { - history.push('/') + history.replace('/') }) .catch(handleFormError) diff --git a/packages/xpub-faraday/app/routes.js b/packages/xpub-faraday/app/routes.js index 98d8d460a2558e90eb0670bb9e6965a0c63f5519..ae7f6e6409763c8dbbaa162403ea7e087937c500 100644 --- a/packages/xpub-faraday/app/routes.js +++ b/packages/xpub-faraday/app/routes.js @@ -1,12 +1,11 @@ import React from 'react' -import { withProps } from 'recompose' import { Route, Switch } from 'react-router-dom' import { AuthenticatedComponent } from 'pubsweet-client' -import Login from 'pubsweet-component-login/LoginContainer' import { Wizard } from 'pubsweet-component-wizard/src/components' import { ManuscriptPage } from 'pubsweet-component-manuscript/src/components' import DashboardPage from 'pubsweet-components-faraday/src/components/Dashboard' +import LoginPage from 'pubsweet-components-faraday/src/components/Login/LoginPage' import { NotFound, InfoPage, @@ -27,8 +26,6 @@ import { import FaradayApp from './FaradayApp' -const LoginPage = withProps({ passwordReset: true })(Login) - const PrivateRoute = ({ component: Component, ...rest }) => ( <Route {...rest} @@ -49,7 +46,7 @@ const Routes = () => ( component={routeParams => ( <SignUpInvitationPage subtitle={null} - title="Author signup" + title="Sign up" type="signup" {...routeParams} />