From d63e124d1c0702898b453be8cfbdd0a5f4620ba5 Mon Sep 17 00:00:00 2001 From: Alaa Yahia <6881345+alaa-yahia@users.noreply.github.com> Date: Mon, 25 Nov 2024 12:49:42 +0200 Subject: [PATCH] fix: [DHIS2-16801] events scheduled for today's date not showing today (#3856) * fix: events scheduled for today's date not showing today --- .../Stages/Stage/StageDetail/hooks/helpers.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/core_modules/capture-core/components/WidgetStagesAndEvents/Stages/Stage/StageDetail/hooks/helpers.js b/src/core_modules/capture-core/components/WidgetStagesAndEvents/Stages/Stage/StageDetail/hooks/helpers.js index 74ae039f19..9d7f31f63f 100644 --- a/src/core_modules/capture-core/components/WidgetStagesAndEvents/Stages/Stage/StageDetail/hooks/helpers.js +++ b/src/core_modules/capture-core/components/WidgetStagesAndEvents/Stages/Stage/StageDetail/hooks/helpers.js @@ -1,6 +1,7 @@ // @flow import React from 'react'; import moment from 'moment'; +import i18n from '@dhis2/d2-i18n'; import { statusTypes, translatedStatusTypes } from 'capture-core/events/statusTypes'; import { convertMomentToDateFormatString } from '../../../../../../utils/converters/date'; import { getSubValues } from '../../getEventDataWithSubValue'; @@ -25,10 +26,14 @@ const getEventStatus = (event: ApiEnrollmentEvent) => { } if (event.status === statusTypes.SCHEDULE) { - if (!event.scheduledAt || !daysUntilDueDate) { + if (!event.scheduledAt) { return { status: statusTypes.SCHEDULE, options: undefined }; } + if (daysUntilDueDate === 0) { + return { status: statusTypes.SCHEDULE, options: i18n.t('Today') }; + } + if (daysUntilDueDate < 14) { return { status: statusTypes.SCHEDULE, options: dueDateFromNow }; }