Skip to content
Snippets Groups Projects
Commit df4bc32e authored by Alexandru Munteanu's avatar Alexandru Munteanu
Browse files

refactor(date-parser): rename date into date-parser

parent c97fc0c2
No related branches found
No related tags found
1 merge request!10Sprint #12
import React from 'react' import React from 'react'
import { get } from 'lodash' import { get } from 'lodash'
import { Date } from 'pubsweet-components-faraday/src/components' import { DateParser } from 'pubsweet-components-faraday/src/components'
// import { AuthorsWithTooltip } from '@pubsweet/ui' // import { AuthorsWithTooltip } from '@pubsweet/ui'
import { import {
...@@ -30,13 +30,13 @@ const ManuscriptDetails = ({ version, project, journal }) => { ...@@ -30,13 +30,13 @@ const ManuscriptDetails = ({ version, project, journal }) => {
<Row> <Row>
<LeftDetails flex={3}> <LeftDetails flex={3}>
<StatusLabel>{mapStatusToLabel(project)}</StatusLabel> <StatusLabel>{mapStatusToLabel(project)}</StatusLabel>
<Date timestamp={get(version, 'submitted')}> <DateParser timestamp={get(version, 'submitted')}>
{(timestamp, days) => ( {(timestamp, days) => (
<DateField> <DateField>
{timestamp} ({days}) {timestamp} ({days})
</DateField> </DateField>
)} )}
</Date> </DateParser>
</LeftDetails> </LeftDetails>
<RightDetails flex={4}> <RightDetails flex={4}>
<ManuscriptType title={manuscriptMeta}> <ManuscriptType title={manuscriptMeta}>
......
...@@ -4,7 +4,7 @@ import { compose } from 'recompose' ...@@ -4,7 +4,7 @@ import { compose } from 'recompose'
import { get, isEmpty } from 'lodash' import { get, isEmpty } from 'lodash'
import { withJournal } from 'xpub-journal' import { withJournal } from 'xpub-journal'
import styled, { css } from 'styled-components' import styled, { css } from 'styled-components'
import { Date } from 'pubsweet-components-faraday/src/components' import { DateParser } from 'pubsweet-components-faraday/src/components'
import { FileItem } from 'pubsweet-components-faraday/src/components/Files' import { FileItem } from 'pubsweet-components-faraday/src/components/Files'
import { ShowMore } from './' import { ShowMore } from './'
...@@ -32,17 +32,17 @@ const ReviewReportCard = ({ ...@@ -32,17 +32,17 @@ const ReviewReportCard = ({
<Underline>{user.name}</Underline> <Underline>{user.name}</Underline>
<span>{user.email}</span> <span>{user.email}</span>
</Text> </Text>
<Date timestamp={submittedOn}> <DateParser timestamp={submittedOn}>
{timestamp => <Text>{timestamp}</Text>} {timestamp => <Text>{timestamp}</Text>}
</Date> </DateParser>
</Row> </Row>
)} )}
<Row> <Row>
<Label>Recommendation</Label> <Label>Recommendation</Label>
{!hasReviewer && ( {!hasReviewer && (
<Date timestamp={submittedOn}> <DateParser timestamp={submittedOn}>
{timestamp => <Text>{timestamp}</Text>} {timestamp => <Text>{timestamp}</Text>}
</Date> </DateParser>
)} )}
</Row> </Row>
<Row> <Row>
......
...@@ -9,7 +9,7 @@ import { ...@@ -9,7 +9,7 @@ import {
withModal, withModal,
ConfirmationModal, ConfirmationModal,
} from 'pubsweet-component-modal/src/components' } from 'pubsweet-component-modal/src/components'
import { Date } from 'pubsweet-components-faraday/src/components' import { DateParser } from 'pubsweet-components-faraday/src/components'
import { AuthorsWithTooltip } from 'pubsweet-component-manuscript/src/molecules' import { AuthorsWithTooltip } from 'pubsweet-component-manuscript/src/molecules'
// import { AuthorsWithTooltip } from '@pubsweet/ui' // import { AuthorsWithTooltip } from '@pubsweet/ui'
...@@ -96,13 +96,13 @@ const DashboardCard = ({ ...@@ -96,13 +96,13 @@ const DashboardCard = ({
<Bottom> <Bottom>
<LeftDetails flex={3}> <LeftDetails flex={3}>
<Status>{mapStatusToLabel(project)}</Status> <Status>{mapStatusToLabel(project)}</Status>
<Date timestamp={get(version, 'submitted')}> <DateParser timestamp={get(version, 'submitted')}>
{(timestamp, daysAgo) => ( {(timestamp, daysAgo) => (
<DateField> <DateField>
{timestamp} ({daysAgo}) {timestamp} ({daysAgo})
</DateField> </DateField>
)} )}
</Date> </DateParser>
</LeftDetails> </LeftDetails>
<RightDetails flex={4}> <RightDetails flex={4}>
<ManuscriptType title={manuscriptMeta}> <ManuscriptType title={manuscriptMeta}>
......
...@@ -4,7 +4,7 @@ import { connect } from 'react-redux' ...@@ -4,7 +4,7 @@ import { connect } from 'react-redux'
import styled from 'styled-components' import styled from 'styled-components'
import { th, Icon } from '@pubsweet/ui' import { th, Icon } from '@pubsweet/ui'
import { compose, withHandlers, withProps } from 'recompose' import { compose, withHandlers, withProps } from 'recompose'
import { Date } from 'pubsweet-components-faraday/src/components' import { DateParser } from 'pubsweet-components-faraday/src/components'
import { revokeReviewer, inviteReviewer } from '../../redux/reviewers' import { revokeReviewer, inviteReviewer } from '../../redux/reviewers'
...@@ -47,9 +47,9 @@ const ReviewersList = ({ ...@@ -47,9 +47,9 @@ const ReviewersList = ({
<StatusText> <StatusText>
{r.status === 'accepted' ? 'Agreed' : r.status} {r.status === 'accepted' ? 'Agreed' : r.status}
</StatusText> </StatusText>
<Date timestamp={r.respondedOn}> <DateParser timestamp={r.respondedOn}>
{timestamp => <DateText>{timestamp}</DateText>} {timestamp => <DateText>{timestamp}</DateText>}
</Date> </DateParser>
</Column> </Column>
{r.status === 'pending' ? ( {r.status === 'pending' ? (
<ResendRevoke <ResendRevoke
......
...@@ -4,7 +4,7 @@ import { connect } from 'react-redux' ...@@ -4,7 +4,7 @@ import { connect } from 'react-redux'
import { th, Icon } from '@pubsweet/ui' import { th, Icon } from '@pubsweet/ui'
import styled, { css } from 'styled-components' import styled, { css } from 'styled-components'
import { compose, withHandlers, withProps } from 'recompose' import { compose, withHandlers, withProps } from 'recompose'
import { Date } from 'pubsweet-components-faraday/src/components' import { DateParser } from 'pubsweet-components-faraday/src/components'
import { import {
withModal2, withModal2,
ConfirmationModal, ConfirmationModal,
...@@ -47,16 +47,20 @@ const TR = ({ ...@@ -47,16 +47,20 @@ const TR = ({
<AcceptedReviewer>{renderAcceptedLabel(index)}</AcceptedReviewer> <AcceptedReviewer>{renderAcceptedLabel(index)}</AcceptedReviewer>
)} )}
</td> </td>
<Date timestamp={r.invitedOn}>{timestamp => <td>{timestamp}</td>}</Date> <DateParser timestamp={r.invitedOn}>
{timestamp => <td>{timestamp}</td>}
</DateParser>
<td> <td>
<StatusText> <StatusText>
{`${r.status === 'accepted' ? 'Agreed: ' : r.status}`} {`${r.status === 'accepted' ? 'Agreed: ' : r.status}`}
</StatusText> </StatusText>
<Date timestamp={r.respondedOn}> <DateParser timestamp={r.respondedOn}>
{timestamp => <DateText>{timestamp}</DateText>} {timestamp => <DateText>{timestamp}</DateText>}
</Date> </DateParser>
</td> </td>
<Date timestamp={submittedOn}>{timestamp => <td>{timestamp}</td>}</Date> <DateParser timestamp={submittedOn}>
{timestamp => <td>{timestamp}</td>}
</DateParser>
<td width={100}> <td width={100}>
{r.status === 'pending' && ( {r.status === 'pending' && (
<ResendRevoke <ResendRevoke
......
...@@ -7,7 +7,8 @@ const getDuration = timestamp => { ...@@ -7,7 +7,8 @@ const getDuration = timestamp => {
return moment.duration(today.diff(stamp)) return moment.duration(today.diff(stamp))
} }
const Date = ({ children, timestamp, daysAgo }) => children(timestamp, daysAgo) const DateParser = ({ children, timestamp, daysAgo }) =>
children(timestamp, daysAgo)
export default compose( export default compose(
withHandlers({ withHandlers({
...@@ -30,4 +31,4 @@ export default compose( ...@@ -30,4 +31,4 @@ export default compose(
daysAgo: renderDaysAgo(), daysAgo: renderDaysAgo(),
timestamp: renderTimestamp(), timestamp: renderTimestamp(),
})), })),
)(Date) )(DateParser)
import * as FormItems from './FormItems' import * as FormItems from './FormItems'
export { FormItems } export { FormItems }
export { default as Date } from './Date'
export { default as Logo } from './Logo' export { default as Logo } from './Logo'
export { default as Spinner } from './Spinner' export { default as Spinner } from './Spinner'
export { default as NotFound } from './NotFound' export { default as NotFound } from './NotFound'
export { default as ErrorPage } from './ErrorPage' export { default as ErrorPage } from './ErrorPage'
export { default as DateParser } from './DateParser'
export { default as ConfirmationPage } from './ConfirmationPage' export { default as ConfirmationPage } from './ConfirmationPage'
...@@ -5,4 +5,4 @@ export { default as AuthorList } from './AuthorList/AuthorList' ...@@ -5,4 +5,4 @@ export { default as AuthorList } from './AuthorList/AuthorList'
export { default as SortableList } from './SortableList/SortableList' export { default as SortableList } from './SortableList/SortableList'
export { DragHandle } from './AuthorList/FormItems' export { DragHandle } from './AuthorList/FormItems'
export { Dropdown, Date, Logo, Spinner } from './UIComponents' export { Dropdown, DateParser, Logo, Spinner } from './UIComponents'
...@@ -6259,6 +6259,10 @@ moment@2.x.x, moment@^2.18.1, moment@^2.20.1, moment@^2.6.0: ...@@ -6259,6 +6259,10 @@ moment@2.x.x, moment@^2.18.1, moment@^2.20.1, moment@^2.6.0:
version "2.20.1" version "2.20.1"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.20.1.tgz#d6eb1a46cbcc14a2b2f9434112c1ff8907f313fd" resolved "https://registry.yarnpkg.com/moment/-/moment-2.20.1.tgz#d6eb1a46cbcc14a2b2f9434112c1ff8907f313fd"
moment@^2.22.1:
version "2.22.1"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.22.1.tgz#529a2e9bf973f259c9643d237fda84de3a26e8ad"
morgan@^1.8.2: morgan@^1.8.2:
version "1.9.0" version "1.9.0"
resolved "https://registry.yarnpkg.com/morgan/-/morgan-1.9.0.tgz#d01fa6c65859b76fcf31b3cb53a3821a311d8051" resolved "https://registry.yarnpkg.com/morgan/-/morgan-1.9.0.tgz#d01fa6c65859b76fcf31b3cb53a3821a311d8051"
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment