import React, { Fragment } from 'react' import styled from 'styled-components' import { isEmpty, get } from 'lodash' import { Text, paddingHelper, ReviewerDetails, HERecommendation, ManuscriptHeader, ManuscriptAssignHE, ManuscriptMetadata, ManuscriptDetailsTop, ResponseToInvitation, ManuscriptEicDecision, SubmitRevision, } from 'pubsweet-component-faraday-ui' import ReviewerReportCard from './ReviewReportCard' import ReviewerReportForm from './ReviewerReportForm' import EditorialCommentCard from './EditorialCommentCard' const messagesLabel = { 'return-to-handling-editor': 'Comments for Handling Editor', reject: 'Comments for Author', } const ManuscriptLayout = ({ history, assignHE, revokeHE, currentUser, getSignedUrl, editorInChief, handlingEditors, createRecommendation, editorialRecommendations, journal = {}, collection = {}, fragment = {}, changeForm, isFetching, fetchingError, formValues, heExpanded, onHEResponse, toggleAssignHE, onInviteReviewer, toggleHEResponse, heResponseExpanded, onReviewerResponse, onResendReviewerInvite, onRevokeReviewerInvite, toggleReviewerResponse, invitationsWithReviewers, publonReviewers, reviewerResponseExpanded, pendingOwnRecommendation, toggleReviewerRecommendations, reviewerRecommendationExpanded, shouldReview, submittedOwnRecommendation, reviewerReports, onEditorialRecommendation, reviewerRecommendations, toggleReviewerDetails, reviewerDetailsExpanded, toggleHeRecommendation, heRecommendationExpanded, onInvitePublonReviewer, submitRevision, }) => ( <Root pb={30}> {!isEmpty(collection) && !isEmpty(fragment) ? ( <Fragment> <ManuscriptDetailsTop collection={collection} currentUser={currentUser} fragment={fragment} getSignedUrl={getSignedUrl} history={history} /> <ManuscriptHeader collection={collection} currentUser={currentUser} editorInChief={editorInChief} fragment={fragment} handlingEditors={handlingEditors} inviteHE={toggleAssignHE} isFetching={isFetching.editorsFetching} journal={journal} resendInvitation={assignHE} revokeInvitation={revokeHE} /> <ManuscriptMetadata currentUser={currentUser} fragment={fragment} getSignedUrl={getSignedUrl} /> {get(currentUser, 'permissions.canSubmitRevision', false) && ( <SubmitRevision {...submitRevision} /> )} {get(currentUser, 'permissions.canViewEditorialComments', true) && ( <EditorialCommentCard expanded={heRecommendationExpanded} journal={journal} reports={editorialRecommendations} toggle={toggleHeRecommendation} /> )} {submittedOwnRecommendation && ( <ReviewerReportCard getSignedUrl={getSignedUrl} journal={journal} report={submittedOwnRecommendation} token={get(currentUser, 'token')} /> )} {shouldReview && ( <ReviewerReportForm changeForm={changeForm} expanded={reviewerRecommendationExpanded} formValues={get(formValues, 'reviewerReport', {})} modalKey="reviewer-report" project={collection} review={pendingOwnRecommendation} toggle={toggleReviewerRecommendations} token={get(currentUser, 'token')} version={fragment} /> )} {get(currentUser, 'isInvitedHE', false) && ( <ResponseToInvitation commentsOn="decline" expanded={heResponseExpanded} formValues={formValues.responseToInvitation} label="Do you agree to be the handling editor for this manuscript?" onResponse={onHEResponse} title="Respond to Editorial Invitation" toggle={toggleHEResponse} /> )} {get(currentUser, 'isInvitedToReview', false) && ( <ResponseToInvitation expanded={reviewerResponseExpanded} label="Do you agree to review this manuscript?" onResponse={onReviewerResponse} title="Respond to Invitation to Review" toggle={toggleReviewerResponse} /> )} <ManuscriptAssignHE assignHE={assignHE} currentUser={currentUser} expanded={heExpanded} handlingEditors={handlingEditors} isFetching={isFetching.editorsFetching} toggle={toggleAssignHE} /> {get(currentUser, 'permissions.canViewReviewersDetails', false) && ( <ReviewerDetails currentUser={currentUser} expanded={reviewerDetailsExpanded} fetchingError={fetchingError} fragment={fragment} getSignedUrl={getSignedUrl} highlight={reviewerReports.length === 0} invitations={invitationsWithReviewers} isFetching={isFetching.publonsFetching} journal={journal} mb={2} onInvitePublonReviewer={onInvitePublonReviewer} onInviteReviewer={onInviteReviewer} onResendReviewerInvite={onResendReviewerInvite} onRevokeReviewerInvite={onRevokeReviewerInvite} publonReviewers={publonReviewers} reviewerReports={reviewerReports} scrollIntoView toggle={toggleReviewerDetails} /> )} {get(currentUser, 'permissions.canMakeHERecommendation', false) && (!invitationsWithReviewers.length || reviewerRecommendations.length > 0) && ( <HERecommendation formValues={get(formValues, 'editorialRecommendation', {})} hasReviewerReports={reviewerRecommendations.length > 0} highlight={reviewerRecommendations.length > 0} modalKey="heRecommendation" onRecommendationSubmit={onEditorialRecommendation} /> )} {get(currentUser, 'permissions.canMakeDecision', false) && ( <ManuscriptEicDecision collection={collection} formValues={get(formValues, 'eicDecision')} highlight={editorialRecommendations.length > 0} messagesLabel={messagesLabel} mt={2} submitDecision={createRecommendation} /> )} </Fragment> ) : ( <Text>Loading...</Text> )} </Root> ) export default ManuscriptLayout // #region styles const Root = styled.div` overflow-y: visible; min-height: 70vh; ${paddingHelper}; ` // #endregion