diff --git a/api/src/components/flag/controller.ts b/api/src/components/flag/controller.ts index cd4a70086..42518553f 100644 --- a/api/src/components/flag/controller.ts +++ b/api/src/components/flag/controller.ts @@ -81,7 +81,7 @@ export const createFlag = async ( if (doesDuplicateFlagExist) { return response.json(400, { - message: 'An unresolved flag created by you, for this publication and category already exists.' + message: 'An unresolved flag created by you for this publication and category already exists.' }); } diff --git a/ui/src/components/ApprovalsTracker/index.tsx b/ui/src/components/ApprovalsTracker/index.tsx index ad88bd7cf..5d1918e97 100644 --- a/ui/src/components/ApprovalsTracker/index.tsx +++ b/ui/src/components/ApprovalsTracker/index.tsx @@ -218,7 +218,12 @@ const ApprovalsTracker: React.FC = (props): React.ReactElement => { {isCorrespondingUser && !author.linkedUser && author.reminderDate ? ( - <>Reminder sent at {Helpers.formatDateTime(author.reminderDate, 'short')} + <> + Reminder sent at{' '} + + ) : author.linkedUser === props.publicationVersion.createdBy ? ( <>Corresponding author ) : author.confirmedCoAuthor ? ( diff --git a/ui/src/components/BlogCard/index.tsx b/ui/src/components/BlogCard/index.tsx index 6b21e2e28..4d2fb1c85 100644 --- a/ui/src/components/BlogCard/index.tsx +++ b/ui/src/components/BlogCard/index.tsx @@ -21,7 +21,7 @@ const BlogCard: React.FC = (props) => { {shortBlogText}

- By {props.author} | {Helpers.formatDate(props.publishedDate)} + By {props.author} |

diff --git a/ui/src/components/Flag/Comment/index.tsx b/ui/src/components/Flag/Comment/index.tsx index cf6c28f78..0b497c93b 100644 --- a/ui/src/components/Flag/Comment/index.tsx +++ b/ui/src/components/Flag/Comment/index.tsx @@ -22,7 +22,7 @@ const Comment: React.FC = (props): React.ReactElement => ( {props.flagComment.user.firstName} {props.flagComment.user.lastName} - Posted: {Helpers.formatDate(props.flagComment.createdAt)} + Posted:
diff --git a/ui/src/components/Flag/Preview/index.tsx b/ui/src/components/Flag/Preview/index.tsx index 97c8f6be4..d998b45a3 100644 --- a/ui/src/components/Flag/Preview/index.tsx +++ b/ui/src/components/Flag/Preview/index.tsx @@ -33,7 +33,7 @@ const Preview: React.FC = (props) => ( Flagged by {props.flag.user.firstName} {props.flag.user.lastName},{' '} - {Helpers.formatDate(props.flag.createdAt)} + ); diff --git a/ui/src/components/Publication/BookmarkedPublications/index.tsx b/ui/src/components/Publication/BookmarkedPublications/index.tsx index f01ce4996..541b22430 100644 --- a/ui/src/components/Publication/BookmarkedPublications/index.tsx +++ b/ui/src/components/Publication/BookmarkedPublications/index.tsx @@ -36,11 +36,17 @@ const BookmarkedPublications: React.FC = (props): React.ReactElement => { {props.publication.publishedDate ? ( - Published: {Helpers.formatDate(props.publication.publishedDate)} + Published:{' '} + ) : ( - Last updated: {Helpers.formatDate(props.publication.updatedAt)} + Last updated:{' '} + )}
diff --git a/ui/src/components/Publication/Creation/LinkedItems/LinkedPublicationRow.tsx b/ui/src/components/Publication/Creation/LinkedItems/LinkedPublicationRow.tsx index c66a326d8..f077add4a 100644 --- a/ui/src/components/Publication/Creation/LinkedItems/LinkedPublicationRow.tsx +++ b/ui/src/components/Publication/Creation/LinkedItems/LinkedPublicationRow.tsx @@ -27,9 +27,12 @@ const LinkedPublicationRow: React.FC = (props): React.ReactElement => { {props.linkedPublication.title}

- + + {props.linkedPublication.authorFirstName[0]}. {props.linkedPublication.authorLastName} diff --git a/ui/src/components/Publication/Creation/LinkedItems/LinkedPublicationsCombobox.tsx b/ui/src/components/Publication/Creation/LinkedItems/LinkedPublicationsCombobox.tsx index 1fdafd6dd..1b4e62460 100644 --- a/ui/src/components/Publication/Creation/LinkedItems/LinkedPublicationsCombobox.tsx +++ b/ui/src/components/Publication/Creation/LinkedItems/LinkedPublicationsCombobox.tsx @@ -133,8 +133,11 @@ const LinkedPublicationsCombobox: React.FC = (p

{publicationVersion.title}

- {publicationVersion.publishedDate && - Helpers.formatDate(publicationVersion.publishedDate)} + {publicationVersion.publishedDate && ( + + )} , diff --git a/ui/src/components/Publication/SimpleResult/index.tsx b/ui/src/components/Publication/SimpleResult/index.tsx index a12ae500b..f82ae3934 100644 --- a/ui/src/components/Publication/SimpleResult/index.tsx +++ b/ui/src/components/Publication/SimpleResult/index.tsx @@ -42,11 +42,17 @@ const SimpleResult: React.FC = (props): React.ReactElement => { {props.publicationVersion.publishedDate ? ( - Published: {Helpers.formatDate(props.publicationVersion.publishedDate)} + Published:{' '} + ) : ( - Last updated: {Helpers.formatDate(props.publicationVersion.updatedAt)} + Last updated:{' '} + )}
diff --git a/ui/src/pages/blog/[slug].tsx b/ui/src/pages/blog/[slug].tsx index 701d10403..66cf636a1 100644 --- a/ui/src/pages/blog/[slug].tsx +++ b/ui/src/pages/blog/[slug].tsx @@ -177,7 +177,8 @@ type Props = { const IndividualBlogPage: NextPage = (props) => { const router = useRouter(); - const { title, author, content, publishedDate } = props.blog.fields; + const { title, author, content } = props.blog.fields; + const [publishedDate, setPublishedDate] = React.useState(String(props.blog.fields.publishedDate)); const { canGoBack } = router.query as { canGoBack: string }; @@ -187,6 +188,13 @@ const IndividualBlogPage: NextPage = (props) => { const pageTitle = `${title} - ${Config.urls.base.title}`; + // This is required to ensure that we don't encounter hydration errors when we format the published + // date on the client. Normally we use suppressHydrationWarning but that only works one level down, + // and we're passing the value to a subcomponent. + React.useEffect(() => { + setPublishedDate(Helpers.formatDate(props.blog.fields.publishedDate)); + }, [props.blog.fields.publishedDate]); + return ( <> @@ -211,7 +219,7 @@ const IndividualBlogPage: NextPage = (props) => {
{documentToReactComponents(content, renderOptions)} diff --git a/ui/src/pages/publications/[id]/flag/[flagId]/index.tsx b/ui/src/pages/publications/[id]/flag/[flagId]/index.tsx index 5caa500b7..28f902e8a 100644 --- a/ui/src/pages/publications/[id]/flag/[flagId]/index.tsx +++ b/ui/src/pages/publications/[id]/flag/[flagId]/index.tsx @@ -230,7 +230,10 @@ const FlagThread: Next.NextPage = (props): JSX.Element => {

This publication was red flagged on{' '} - {Helpers.formatDate(data.createdAt)}, by{' '} + + , by{' '}