diff --git a/packages/component-manuscript/src/components/ManuscriptPage.js b/packages/component-manuscript/src/components/ManuscriptPage.js index 4b98dbb39f55ed22db00970e3d881fae971977d8..e40b6a0a6e26b4bb427b7fcd4ba824231b90fd71 100644 --- a/packages/component-manuscript/src/components/ManuscriptPage.js +++ b/packages/component-manuscript/src/components/ManuscriptPage.js @@ -3,7 +3,7 @@ import { actions } from 'pubsweet-client' import { ConnectPage } from 'xpub-connect' import { withJournal } from 'xpub-journal' import { withRouter } from 'react-router-dom' -import { head, get, isUndefined } from 'lodash' +import { head, get, last, isUndefined } from 'lodash' import { getFormValues, change as changeForm } from 'redux-form' import { selectFragment, @@ -84,7 +84,7 @@ export default compose( withJournal, withRouter, withFetching, - withState('publonReviewers', 'setPub', []), + withState('publonReviewers', 'setPublonsReviewers', []), withState('editorInChief', 'setEiC', 'N/A'), ConnectPage(({ match }) => [ actions.getCollection({ id: match.params.project }), @@ -222,8 +222,6 @@ export default compose( setEiC(`${firstName} ${lastName}`) } }, - setPublons: ({ setPub }) => (publonReviewers = []) => - setPub(publonReviewers), assignHE: ({ assignHandlingEditor, fetchUpdatedCollection, @@ -423,7 +421,6 @@ export default compose( collection, fragment, fetchUpdatedCollection, - setPublons, setFetching: setListFetching, setError, clearError, @@ -433,19 +430,15 @@ export default compose( reviewerData: values, fragmentId: fragment.id, collectionId: collection.id, - isPublons: true, + isPublon: true, }) .then(() => { setFetching(false) hideModal() fetchUpdatedCollection() - getPublonsReviewers({ - fragmentId: fragment.id, - setPublons, - setFetching: setListFetching, - setError, - clearError, - }) + getPublonsReviewers('plm') // fragment.id) + .then(r => console.log('dupa publons', r)) + .catch(handleError(setError)) }) .catch(err => { setFetching(false) @@ -485,11 +478,11 @@ export default compose( match, history, location, - setPublons, shouldReview, reviewerReports, setEditorInChief, clearCustomError, + setPublonsReviewers, hasManuscriptFailure, fetchUpdatedCollection, currentUser: { @@ -523,13 +516,26 @@ export default compose( ) if (canInviteReviewers) { - getPublonsReviewers({ - fragmentId, - setPublons, - setFetching, - setError, - clearError, - }) + clearError() + setFetching(true) + getPublonsReviewers(fragmentId) + .then(res => { + setFetching(false) + setPublonsReviewers( + res.map(r => { + const names = r.name.split(' ') + return { + ...r, + firstName: names[0], + lastName: last(names), + } + }), + ) + }) + .catch(e => { + setFetching(false) + handleError(setError)(e) + }) } if (isInvitedHE) { diff --git a/packages/component-manuscript/src/components/utils.js b/packages/component-manuscript/src/components/utils.js index 3fd58fbc9af7b3c79394b81f3cfde6162c2d09a3..8d9a2d6cc3ad46d4304e2fc07dcfb57731c49c3b 100644 --- a/packages/component-manuscript/src/components/utils.js +++ b/packages/component-manuscript/src/components/utils.js @@ -306,22 +306,5 @@ export const parseEicDecision = ({ decision, message }) => ({ }) // handle publons -export const getPublonsAPI = fragmentId => +export const getPublonsReviewers = fragmentId => apiGet(`/fragments/${fragmentId}/publons`) - -export const getPublonsReviewers = ({ - fragmentId, - setPublons, - setFetching, - setError, - clearError, -}) => { - clearError() - setFetching(true) - getPublonsAPI(fragmentId) - .then(res => { - setPublons(res) - setFetching(false) - }) - .catch(handleError(setError)) -}