From f8db7627370fb531ca8203a9d2fea45da590b4f9 Mon Sep 17 00:00:00 2001
From: Jen Jones Arnesen
Date: Mon, 18 Mar 2024 17:11:34 +0100
Subject: [PATCH 1/2] fix: get server date to show correct date
---
src/components/AboutAOUnit/AboutAOUnit.js | 17 ++-
.../InterpretationThread.js | 12 +-
.../InterpretationsUnit/InterpretationList.js | 4 +-
.../Interpretations/common/Message/Message.js | 106 ++++++++++--------
4 files changed, 83 insertions(+), 56 deletions(-)
diff --git a/src/components/AboutAOUnit/AboutAOUnit.js b/src/components/AboutAOUnit/AboutAOUnit.js
index 0fb7fb78e..76002a453 100644
--- a/src/components/AboutAOUnit/AboutAOUnit.js
+++ b/src/components/AboutAOUnit/AboutAOUnit.js
@@ -1,4 +1,8 @@
-import { useDataQuery, useDataMutation } from '@dhis2/app-runtime'
+import {
+ useDataQuery,
+ useDataMutation,
+ useTimeZoneConversion,
+} from '@dhis2/app-runtime'
import i18n from '@dhis2/d2-i18n'
import { Parser as RichTextParser } from '@dhis2/d2-ui-rich-text'
import {
@@ -57,6 +61,7 @@ const getUnsubscribeMutation = (type, id) => ({
const AboutAOUnit = forwardRef(({ type, id, renderId }, ref) => {
const [isExpanded, setIsExpanded] = useState(true)
+ const { fromServerDate } = useTimeZoneConversion()
const queries = useMemo(() => getQueries(type), [type])
@@ -208,7 +213,7 @@ const AboutAOUnit = forwardRef(({ type, id, renderId }, ref) => {
{i18n.t('Last updated {{time}}', {
time: moment(
- data.ao.lastUpdated
+ fromServerDate(data.ao.lastUpdated)
).fromNow(),
})}
@@ -219,7 +224,9 @@ const AboutAOUnit = forwardRef(({ type, id, renderId }, ref) => {
'Created {{time}} by {{author}}',
{
time: moment(
- data.ao.created
+ fromServerDate(
+ data.ao.created
+ )
).fromNow(),
author: data.ao.createdBy
.displayName,
@@ -227,7 +234,9 @@ const AboutAOUnit = forwardRef(({ type, id, renderId }, ref) => {
)
: i18n.t('Created {{time}}', {
time: moment(
- data.ao.created
+ fromServerDate(
+ data.ao.created
+ )
).fromNow(),
})}
diff --git a/src/components/Interpretations/InterpretationModal/InterpretationThread.js b/src/components/Interpretations/InterpretationModal/InterpretationThread.js
index cf352317b..9d350c59c 100644
--- a/src/components/Interpretations/InterpretationModal/InterpretationThread.js
+++ b/src/components/Interpretations/InterpretationModal/InterpretationThread.js
@@ -1,3 +1,4 @@
+import { useTimeZoneConversion } from '@dhis2/app-runtime'
import { IconClock16, colors } from '@dhis2/ui'
import cx from 'classnames'
import moment from 'moment'
@@ -16,6 +17,7 @@ const InterpretationThread = ({
onThreadUpdated,
downloadMenuComponent: DownloadMenu,
}) => {
+ const { fromServerDate } = useTimeZoneConversion()
const focusRef = useRef()
useEffect(() => {
@@ -31,10 +33,16 @@ const InterpretationThread = ({
- {moment(interpretation.created).format('LLL')}
+ {moment(fromServerDate(interpretation.created)).format(
+ 'LLL'
+ )}
{DownloadMenu && (
-
+
)}
{
+ const { fromServerDate } = useTimeZoneConversion()
const interpretationsByDate = interpretations.reduce(
(groupedInterpretations, interpretation) => {
const date = interpretation.created.split('T')[0]
@@ -50,7 +52,7 @@ export const InterpretationList = ({
diff --git a/src/components/Interpretations/common/Message/Message.js b/src/components/Interpretations/common/Message/Message.js
index 0253cb5cb..016e8b9d0 100644
--- a/src/components/Interpretations/common/Message/Message.js
+++ b/src/components/Interpretations/common/Message/Message.js
@@ -1,63 +1,71 @@
+import { useTimeZoneConversion } from '@dhis2/app-runtime'
import { Parser as RichTextParser } from '@dhis2/d2-ui-rich-text'
import { UserAvatar, spacers, colors } from '@dhis2/ui'
import moment from 'moment'
import PropTypes from 'prop-types'
import React from 'react'
-const Message = ({ children, text, created, username }) => (
- -
-
-
- {username}
-
-
-
- {text}
-
- {children}
-
-
-)
+ .footer {
+ display: flex;
+ flex-direction: column;
+ align-items: flex-start;
+ gap: ${spacers.dp8};
+ }
+ `}
+
+ )
+}
Message.propTypes = {
children: PropTypes.node.isRequired,
From 026926017137490ccf216559485472a696248ba0 Mon Sep 17 00:00:00 2001
From: Jen Jones Arnesen
Date: Wed, 20 Mar 2024 09:01:30 +0100
Subject: [PATCH 2/2] fix: dont convert date for download
---
.../InterpretationModal/InterpretationThread.js | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/src/components/Interpretations/InterpretationModal/InterpretationThread.js b/src/components/Interpretations/InterpretationModal/InterpretationThread.js
index 9d350c59c..262994e1f 100644
--- a/src/components/Interpretations/InterpretationModal/InterpretationThread.js
+++ b/src/components/Interpretations/InterpretationModal/InterpretationThread.js
@@ -38,11 +38,7 @@ const InterpretationThread = ({
)}
{DownloadMenu && (
-
+
)}