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..262994e1f 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,7 +33,9 @@ const InterpretationThread = ({
- {moment(interpretation.created).format('LLL')} + {moment(fromServerDate(interpretation.created)).format( + 'LLL' + )}
{DownloadMenu && ( diff --git a/src/components/Interpretations/InterpretationsUnit/InterpretationList.js b/src/components/Interpretations/InterpretationsUnit/InterpretationList.js index 22de9c3a0..f16d78514 100644 --- a/src/components/Interpretations/InterpretationsUnit/InterpretationList.js +++ b/src/components/Interpretations/InterpretationsUnit/InterpretationList.js @@ -1,3 +1,4 @@ +import { useTimeZoneConversion } from '@dhis2/app-runtime' import { IconCalendar24, colors, spacers } from '@dhis2/ui' import moment from 'moment' import PropTypes from 'prop-types' @@ -25,6 +26,7 @@ export const InterpretationList = ({ refresh, disabled, }) => { + 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 }) => ( -
  1. -
    - - {username} - -
    -
    - {text} -
    -
    {children}
    - -
  2. -) + .footer { + display: flex; + flex-direction: column; + align-items: flex-start; + gap: ${spacers.dp8}; + } + `} + + ) +} Message.propTypes = { children: PropTypes.node.isRequired,