From 403db18c8052d9d3099a6224f23e33156123a8f2 Mon Sep 17 00:00:00 2001
From: Bogdan Cochior <bogdan.cochior@thinslices.com>
Date: Thu, 19 Apr 2018 11:45:15 +0300
Subject: [PATCH] feat(authors): add author details on dashboard card and on
 tooltip

---
 .../src/helpers/Collection.js                      |  5 +++++
 .../src/routes/collectionsUsers/get.js             |  2 +-
 .../src/components/Dashboard/DashboardCard.js      | 14 +++++++-------
 packages/xpub-faraday-server/src/AuthorBackend.js  |  2 +-
 .../xpub-faraday-server/src/AuthorBackend.test.js  |  2 +-
 5 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/packages/component-user-manager/src/helpers/Collection.js b/packages/component-user-manager/src/helpers/Collection.js
index 40cf70f3b..85853a987 100644
--- a/packages/component-user-manager/src/helpers/Collection.js
+++ b/packages/component-user-manager/src/helpers/Collection.js
@@ -13,6 +13,11 @@ module.exports = {
     collection.authors = collection.authors || []
     const author = {
       userId: user.id,
+      firstName: user.firstName || '',
+      lastName: user.lastName || '',
+      email: user.email,
+      title: user.title || '',
+      affiliation: user.affiliation || '',
       isSubmitting,
       isCorresponding,
     }
diff --git a/packages/component-user-manager/src/routes/collectionsUsers/get.js b/packages/component-user-manager/src/routes/collectionsUsers/get.js
index 7f11e412a..1d6b395dd 100644
--- a/packages/component-user-manager/src/routes/collectionsUsers/get.js
+++ b/packages/component-user-manager/src/routes/collectionsUsers/get.js
@@ -2,7 +2,7 @@ const helpers = require('../../helpers/helpers')
 const teamHelper = require('../../helpers/Team')
 
 module.exports = models => async (req, res) => {
-  // TO DO: add authsom
+  // TO DO: add authsome
   const { collectionId } = req.params
   try {
     const collection = await models.Collection.find(collectionId)
diff --git a/packages/components-faraday/src/components/Dashboard/DashboardCard.js b/packages/components-faraday/src/components/Dashboard/DashboardCard.js
index dc6058df1..1d5bf38bc 100644
--- a/packages/components-faraday/src/components/Dashboard/DashboardCard.js
+++ b/packages/components-faraday/src/components/Dashboard/DashboardCard.js
@@ -108,14 +108,14 @@ const DashboardCard = ({
         <DetailsView>
           <Top>
             <AuthorList>
-              {version.authors.map(
+              {project.authors.map(
                 (
                   {
                     affiliation,
                     firstName,
                     lastName,
-                    middleName,
                     email,
+                    userId,
                     isSubmitting,
                     isCorresponding,
                   },
@@ -124,16 +124,15 @@ const DashboardCard = ({
                 ) => (
                   <AuthorTooltip
                     affiliation={affiliation}
-                    authorName={`${firstName} ${lastName}`}
+                    authorName={`${firstName || ''} ${lastName || ''}`}
                     email={email}
                     isCorresponding={isCorresponding}
                     isSubmitting={isSubmitting}
-                    key={email}
+                    currentUser={currentUser}
+                    key={userId}
                   >
                     <Author>
-                      <AuthorName>
-                        {firstName} {middleName} {lastName}
-                      </AuthorName>
+                      <AuthorName>{`${firstName} ${lastName}`}</AuthorName>
                       {isSubmitting && <AuthorStatus>SA</AuthorStatus>}
                       {isCorresponding && <AuthorStatus>CA</AuthorStatus>}
                       {arr.length - 1 === index ? '' : ','}
@@ -224,6 +223,7 @@ const AuthorList = styled.span`
 const AuthorName = styled.span`
   text-decoration: underline;
   padding-left: 2px;
+  cursor: default;
 `
 const Author = styled.div`
   padding-right: ${th('subGridUnit')};
diff --git a/packages/xpub-faraday-server/src/AuthorBackend.js b/packages/xpub-faraday-server/src/AuthorBackend.js
index 3c0fbcc1d..d05bb8349 100644
--- a/packages/xpub-faraday-server/src/AuthorBackend.js
+++ b/packages/xpub-faraday-server/src/AuthorBackend.js
@@ -40,7 +40,7 @@ const AuthorBackend = app => {
           if (submittingAuthors.length > 0) {
             res
               .status(400)
-              .json({ error: 'There can only be one sumbitting author' })
+              .json({ error: 'There can only be one submitting author' })
             return
           }
         }
diff --git a/packages/xpub-faraday-server/src/AuthorBackend.test.js b/packages/xpub-faraday-server/src/AuthorBackend.test.js
index 697e0b823..ab4ee126d 100644
--- a/packages/xpub-faraday-server/src/AuthorBackend.test.js
+++ b/packages/xpub-faraday-server/src/AuthorBackend.test.js
@@ -130,7 +130,7 @@ describe('Author Backend API', () => {
       .post(createAuthorUrl)
       .set('Authorization', 'Bearer 123')
       .send(testFixtures.authors.newSubmittingAuthor)
-      .expect(400, '{"error":"There can only be one sumbitting author"}')
+      .expect(400, '{"error":"There can only be one submitting author"}')
   })
 
   it('should return success when saving a new author', () => {
-- 
GitLab