diff --git a/packages/components-faraday/src/components/Dashboard/DashboardCard.js b/packages/components-faraday/src/components/Dashboard/DashboardCard.js index 1c9cff36bb2b31a8c9d614bb8b54e8fdabefd9d9..bf2882df847d0071004dd88d8aaa50e4921cbd29 100644 --- a/packages/components-faraday/src/components/Dashboard/DashboardCard.js +++ b/packages/components-faraday/src/components/Dashboard/DashboardCard.js @@ -34,7 +34,6 @@ const DashboardCard = ({ ...rest }) => { const { submitted, title, type } = parseVersion(version) - const status = get(project, 'status') const metadata = get(version, 'metadata') const files = get(version, 'files') const customId = project.customId || project.id.split('-')[0] @@ -81,7 +80,7 @@ const DashboardCard = ({ </Top> <Bottom> <LeftDetails flex="3"> - <Status>{mapStatusToLabel(status)}</Status> + <Status>{mapStatusToLabel(project)}</Status> <DateField>{submitted || ''}</DateField> </LeftDetails> <RightDetails flex="4"> @@ -197,22 +196,22 @@ export default compose( // this can be changed, but it works; cba if (isAdmin || isEic) { - if (status === 'submitted' || status === 'he-invited') + if (status === 'submitted' || status === 'heInvited') return <EditorInChiefActions project={project} /> - if (status === 'under-review') + if (status === 'underReview') return <AssignedHE>{get(handlingEditor, 'name')}</AssignedHE> return <div /> } if (isHe) { - if (status === 'he-invited') + if (status === 'heInvited') return ( <HandlingEditorActions currentUser={currentUser} project={project} /> ) - if (status === 'under-review') + if (status === 'underReview' || status === 'heAssigned') return <AssignedHE>{get(handlingEditor, 'name')}</AssignedHE> } }, diff --git a/packages/components-faraday/src/components/utils.js b/packages/components-faraday/src/components/utils.js index a511843124f0761e17273b7292e8aabc3bef7380..a6d5812e37cd28eb845dc1bcef44b5e4a0eb9d63 100644 --- a/packages/components-faraday/src/components/utils.js +++ b/packages/components-faraday/src/components/utils.js @@ -1,5 +1,5 @@ import moment from 'moment' -import { get, find } from 'lodash' +import { get, find, capitalize } from 'lodash' export const parseTitle = version => { const title = get(version, 'metadata.title') @@ -43,7 +43,7 @@ export const parseVersion = version => ({ export const parseJournalIssue = (journal, metadata) => journal.issueTypes.find(t => t.value === get(metadata, 'issue')) -export const mapStatusToLabel = status => { +export const mapStatusToLabel2 = status => { switch (status) { case 'he-invited': return 'Handling Editor Assigned' @@ -56,6 +56,15 @@ export const mapStatusToLabel = status => { } } +export const mapStatusToLabel = ({ visibleStatus, status }) => { + if (visibleStatus) { + return visibleStatus + } else if (status) { + return capitalize(status) + } + return 'Draft' +} + export const handleError = fn => e => { fn(get(JSON.parse(e.response), 'error') || 'Oops! Something went wrong!') }