From 703546ad9d11e8ac1934d6074baebe11da5f774e Mon Sep 17 00:00:00 2001 From: Tony Valle Date: Tue, 10 Oct 2023 14:34:04 +0200 Subject: [PATCH] fix: translations in enrollment widget --- .../components/WidgetEnrollment/Date/Date.component.js | 3 +++ .../WidgetEnrollment/WidgetEnrollment.component.js | 3 +++ .../WidgetEnrollment/WidgetEnrollment.container.js | 7 +++++-- .../components/WidgetEnrollment/enrollment.types.js | 1 + .../components/WidgetEnrollment/hooks/useProgram.js | 2 +- 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/core_modules/capture-core/components/WidgetEnrollment/Date/Date.component.js b/src/core_modules/capture-core/components/WidgetEnrollment/Date/Date.component.js index f3c7f36617..0fdba91aea 100644 --- a/src/core_modules/capture-core/components/WidgetEnrollment/Date/Date.component.js +++ b/src/core_modules/capture-core/components/WidgetEnrollment/Date/Date.component.js @@ -17,6 +17,7 @@ import { dataElementTypes } from '../../../metaData'; type Props = { date: string, dateLabel: string, + locale: string, editEnabled: boolean, displayAutoGeneratedEventWarning: boolean, onSave: (string) => void, @@ -66,6 +67,7 @@ const styles = { const DateComponentPlain = ({ date, dateLabel, + locale, editEnabled, displayAutoGeneratedEventWarning, onSave, @@ -103,6 +105,7 @@ const DateComponentPlain = ({ className={classes.calendar} label={dateLabel} date={selectedDate} + locale={locale} onDateSelect={dateChangeHandler} /> diff --git a/src/core_modules/capture-core/components/WidgetEnrollment/WidgetEnrollment.component.js b/src/core_modules/capture-core/components/WidgetEnrollment/WidgetEnrollment.component.js index 15ebdb7c41..23a8763372 100644 --- a/src/core_modules/capture-core/components/WidgetEnrollment/WidgetEnrollment.component.js +++ b/src/core_modules/capture-core/components/WidgetEnrollment/WidgetEnrollment.component.js @@ -50,6 +50,7 @@ export const WidgetEnrollmentPlain = ({ enrollment = {}, program = {}, ownerOrgUnit = {}, + locale, refetchEnrollment, refetchTEI, initError, @@ -97,6 +98,7 @@ export const WidgetEnrollmentPlain = ({ item.program === programId) .every(item => item.status !== plainStatus.ACTIVE); const containsAutoGeneratedEvent = program && program.programStages.some(({ autoGenerateEvent }) => autoGenerateEvent); - const error = errorEnrollment || errorProgram || errorOwnerOrgUnit || errorOrgUnit; + const error = errorEnrollment || errorProgram || errorOwnerOrgUnit || errorOrgUnit || errorLocale; if (error) { log.error(errorCreator('Enrollment widget could not be loaded')({ error })); @@ -62,7 +64,8 @@ export const WidgetEnrollment = ({ refetchEnrollment={refetchEnrollment} refetchTEI={refetchTEI} ownerOrgUnit={{ id: ownerOrgUnit, displayName }} - loading={!(enrollment && program && displayName)} + locale={locale} + loading={!(enrollment && program && displayName && locale)} onDelete={onDelete} onAddNew={onAddNew} updateEnrollmentDate={updateEnrollmentDate} diff --git a/src/core_modules/capture-core/components/WidgetEnrollment/enrollment.types.js b/src/core_modules/capture-core/components/WidgetEnrollment/enrollment.types.js index d4e14794b8..42e5188ab4 100644 --- a/src/core_modules/capture-core/components/WidgetEnrollment/enrollment.types.js +++ b/src/core_modules/capture-core/components/WidgetEnrollment/enrollment.types.js @@ -18,6 +18,7 @@ export type PlainProps = {| enrollment: Object, program: Object, ownerOrgUnit: Object, + locale: string, refetchEnrollment: QueryRefetchFunction, refetchTEI: QueryRefetchFunction, initError?: FetchError, diff --git a/src/core_modules/capture-core/components/WidgetEnrollment/hooks/useProgram.js b/src/core_modules/capture-core/components/WidgetEnrollment/hooks/useProgram.js index fec7939f6d..4d643cb140 100644 --- a/src/core_modules/capture-core/components/WidgetEnrollment/hooks/useProgram.js +++ b/src/core_modules/capture-core/components/WidgetEnrollment/hooks/useProgram.js @@ -10,7 +10,7 @@ export const useProgram = (programId: string) => { resource: `programs/${programId}`, params: { fields: [ - 'displayIncidentDate,incidentDateLabel,enrollmentDateLabel,onlyEnrollOnce,trackedEntityType[displayName],programStages[autoGenerateEvent],access', + 'displayIncidentDate,displayIncidentDateLabel,displayEnrollmentDateLabel,onlyEnrollOnce,trackedEntityType[displayName],programStages[autoGenerateEvent],access', ], }, },