From 134138b80b98ecb543c009710896b73cca0a35d8 Mon Sep 17 00:00:00 2001 From: Alexandru Munteanu <alexandru.munt@gmail.com> Date: Thu, 19 Apr 2018 10:45:27 +0300 Subject: [PATCH] feat(manuscript-details): create route to accept from email --- packages/component-manuscript/package.json | 6 +++++ .../src/components/Details.js | 27 +++++++++++++++++++ .../src/components/index.js | 1 + .../src/components/utils.js | 10 +++++++ packages/component-manuscript/src/index.js | 5 ++++ packages/xpub-faraday/app/routes.js | 6 +++-- packages/xpub-faraday/config/components.json | 3 ++- 7 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 packages/component-manuscript/package.json create mode 100644 packages/component-manuscript/src/components/Details.js create mode 100644 packages/component-manuscript/src/components/index.js create mode 100644 packages/component-manuscript/src/components/utils.js create mode 100644 packages/component-manuscript/src/index.js diff --git a/packages/component-manuscript/package.json b/packages/component-manuscript/package.json new file mode 100644 index 000000000..110b73775 --- /dev/null +++ b/packages/component-manuscript/package.json @@ -0,0 +1,6 @@ +{ + "name": "pubsweet-component-manuscript", + "version": "0.0.1", + "main": "src", + "license": "MIT" +} diff --git a/packages/component-manuscript/src/components/Details.js b/packages/component-manuscript/src/components/Details.js new file mode 100644 index 000000000..2249fc2a1 --- /dev/null +++ b/packages/component-manuscript/src/components/Details.js @@ -0,0 +1,27 @@ +import React from 'react' +import { connect } from 'react-redux' +import { replace } from 'react-router-redux' +import { compose, lifecycle } from 'recompose' +import { selectCurrentUser } from 'xpub-selectors' + +import { parseSearchParams } from './utils' + +const Details = () => <div>eu sunt manuscript details</div> + +export default compose( + connect( + state => ({ + currentUser: selectCurrentUser(state), + }), + { replace }, + ), + lifecycle({ + componentDidMount() { + const { location, replace } = this.props + const { accept } = parseSearchParams(location.search) + if (accept === 'true') { + replace(location.pathname) + } + }, + }), +)(Details) diff --git a/packages/component-manuscript/src/components/index.js b/packages/component-manuscript/src/components/index.js new file mode 100644 index 000000000..08c9ae908 --- /dev/null +++ b/packages/component-manuscript/src/components/index.js @@ -0,0 +1 @@ +export { default as ManuscriptDetails } from './Details' diff --git a/packages/component-manuscript/src/components/utils.js b/packages/component-manuscript/src/components/utils.js new file mode 100644 index 000000000..4f264402c --- /dev/null +++ b/packages/component-manuscript/src/components/utils.js @@ -0,0 +1,10 @@ +/* eslint-disable */ + +export const parseSearchParams = url => { + const params = new URLSearchParams(url) + const parsedObject = {} + for ([key, value] of params) { + parsedObject[key] = value + } + return parsedObject +} diff --git a/packages/component-manuscript/src/index.js b/packages/component-manuscript/src/index.js new file mode 100644 index 000000000..8d52f148e --- /dev/null +++ b/packages/component-manuscript/src/index.js @@ -0,0 +1,5 @@ +module.exports = { + client: { + components: [() => require('./components')], + }, +} diff --git a/packages/xpub-faraday/app/routes.js b/packages/xpub-faraday/app/routes.js index c17addb48..c65e01a8e 100644 --- a/packages/xpub-faraday/app/routes.js +++ b/packages/xpub-faraday/app/routes.js @@ -5,10 +5,11 @@ import { AuthenticatedComponent } from 'pubsweet-client' import Login from 'pubsweet-component-login/LoginContainer' import Signup from 'pubsweet-component-signup/SignupContainer' -import DashboardPage from 'pubsweet-components-faraday/src/components/Dashboard' import { Wizard } from 'pubsweet-component-wizard/src/components' -import ConfirmationPage from 'pubsweet-components-faraday/src/components/UIComponents/ConfirmationPage' +import { ManuscriptDetails } from 'pubsweet-component-manuscript/src/components' +import DashboardPage from 'pubsweet-components-faraday/src/components/Dashboard' import NotFound from 'pubsweet-components-faraday/src/components/UIComponents/NotFound' +import ConfirmationPage from 'pubsweet-components-faraday/src/components/UIComponents/ConfirmationPage' import { AdminDashboard, AdminUsers, @@ -61,6 +62,7 @@ const Routes = () => ( /> <Route component={SignUpInvitationPage} exact path="/invite" /> <Route component={ReviewerSignUp} exact path="/invite-reviewer" /> + <PrivateRoute component={ManuscriptDetails} exact path="/manu-details" /> <Route component={NotFound} /> </Switch> </FaradayApp> diff --git a/packages/xpub-faraday/config/components.json b/packages/xpub-faraday/config/components.json index 7b325481c..5d3e7cc1f 100644 --- a/packages/xpub-faraday/config/components.json +++ b/packages/xpub-faraday/config/components.json @@ -8,5 +8,6 @@ "@pubsweet/component-aws-s3", "pubsweet-component-invite", "pubsweet-component-user-manager", - "pubsweet-component-email" + "pubsweet-component-email", + "pubsweet-component-manuscript" ] -- GitLab