Skip to content

Commit

Permalink
fix: translations in enrollment widget
Browse files Browse the repository at this point in the history
  • Loading branch information
superskip committed Oct 10, 2023
1 parent ee930cb commit 703546a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { dataElementTypes } from '../../../metaData';
type Props = {
date: string,
dateLabel: string,
locale: string,
editEnabled: boolean,
displayAutoGeneratedEventWarning: boolean,
onSave: (string) => void,
Expand Down Expand Up @@ -66,6 +67,7 @@ const styles = {
const DateComponentPlain = ({
date,
dateLabel,
locale,
editEnabled,
displayAutoGeneratedEventWarning,
onSave,
Expand Down Expand Up @@ -103,6 +105,7 @@ const DateComponentPlain = ({
className={classes.calendar}
label={dateLabel}
date={selectedDate}
locale={locale}
onDateSelect={dateChangeHandler}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const WidgetEnrollmentPlain = ({
enrollment = {},
program = {},
ownerOrgUnit = {},
locale,
refetchEnrollment,
refetchTEI,
initError,
Expand Down Expand Up @@ -97,6 +98,7 @@ export const WidgetEnrollmentPlain = ({
<Date
date={enrollment.enrolledAt}
dateLabel={getEnrollmentDateLabel(program)}
locale={locale}
editEnabled={editDateEnabled}
displayAutoGeneratedEventWarning={displayAutoGeneratedEventWarning}
onSave={updateEnrollmentDate}
Expand All @@ -109,6 +111,7 @@ export const WidgetEnrollmentPlain = ({
<Date
date={enrollment.occurredAt}
dateLabel={getIncidentDateLabel(program)}
locale={locale}
editEnabled={editDateEnabled}
displayAutoGeneratedEventWarning={displayAutoGeneratedEventWarning}
onSave={updateIncidentDate}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useOrganizationUnit } from './hooks/useOrganizationUnit';
import { useTrackedEntityInstances } from './hooks/useTrackedEntityInstances';
import { useEnrollment } from './hooks/useEnrollment';
import { useProgram } from './hooks/useProgram';
import { useUserLocale } from '../../utils/localeData/useUserLocale';
import type { Props } from './enrollment.types';
import { plainStatus } from './constants/status.const';

Expand Down Expand Up @@ -42,11 +43,12 @@ export const WidgetEnrollment = ({
refetch: refetchTEI,
} = useTrackedEntityInstances(teiId, programId);
const { error: errorOrgUnit, displayName } = useOrganizationUnit(ownerOrgUnit);
const { error: errorLocale, locale } = useUserLocale();
const canAddNew = enrollments
.filter(item => 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 }));
Expand All @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type PlainProps = {|
enrollment: Object,
program: Object,
ownerOrgUnit: Object,
locale: string,
refetchEnrollment: QueryRefetchFunction,
refetchTEI: QueryRefetchFunction,
initError?: FetchError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
},
},
Expand Down

0 comments on commit 703546a

Please sign in to comment.