diff --git a/i18n/en.pot b/i18n/en.pot index 7150c6ce89..d3512ccf75 100644 --- a/i18n/en.pot +++ b/i18n/en.pot @@ -5,8 +5,8 @@ msgstr "" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1)\n" -"POT-Creation-Date: 2024-11-11T07:41:42.396Z\n" -"PO-Revision-Date: 2024-11-11T07:41:42.396Z\n" +"POT-Creation-Date: 2024-12-06T11:29:57.874Z\n" +"PO-Revision-Date: 2024-12-06T11:29:57.874Z\n" msgid "Choose one or more dates..." msgstr "Choose one or more dates..." @@ -745,9 +745,6 @@ msgstr "There was an error opening the Page" msgid "There was an error loading the page" msgstr "There was an error loading the page" -msgid "Choose an organisation unit to start reporting" -msgstr "Choose an organisation unit to start reporting" - msgid "Program stage is invalid" msgstr "Program stage is invalid" @@ -804,6 +801,9 @@ msgstr "" "You don't have access to create a {{trackedEntityName}} in the current " "selections" +msgid "Choose an organisation unit to start reporting" +msgstr "Choose an organisation unit to start reporting" + msgid "Choose the {{missingCategories}} to start reporting" msgstr "Choose the {{missingCategories}} to start reporting" @@ -1671,15 +1671,6 @@ msgstr "Follow up" msgid "Choose a program stage to filter by {{label}}" msgstr "Choose a program stage to filter by {{label}}" -msgid "Active enrollments" -msgstr "Active enrollments" - -msgid "Completed enrollments" -msgstr "Completed enrollments" - -msgid "Cancelled enrollments" -msgstr "Cancelled enrollments" - msgid "" "Some enrollments were completed successfully, but there was an error while " "completing the rest. Please see the details below." diff --git a/src/core_modules/capture-core/components/FormFields/New/HOC/withCenterPoint.js b/src/core_modules/capture-core/components/FormFields/New/HOC/withCenterPoint.js index 0ac9861d47..96039d9168 100644 --- a/src/core_modules/capture-core/components/FormFields/New/HOC/withCenterPoint.js +++ b/src/core_modules/capture-core/components/FormFields/New/HOC/withCenterPoint.js @@ -17,7 +17,7 @@ const convertToClientCoordinates = ({ coordinates, type }: { coordinates: any[], const getCenterPoint = (InnerComponent: ComponentType) => (props: Object) => { const { orgUnit, ...passOnProps } = props; - const [orgUnitKey, setOrgUnitKey] = useState(orgUnit.id); + const [orgUnitKey, setOrgUnitKey] = useState(orgUnit?.id); const [shouldFetch, setShouldFetch] = useState(false); const queryKey = ['organisationUnit', 'geometry', orgUnitKey]; const queryFn = { @@ -28,8 +28,8 @@ const getCenterPoint = (InnerComponent: ComponentType) => (props: Object) = }, }; const queryOptions = useMemo( - () => ({ enabled: Boolean(orgUnit.id) && shouldFetch }), - [shouldFetch, orgUnit.id], + () => ({ enabled: Boolean(orgUnit?.id) && shouldFetch }), + [shouldFetch, orgUnit?.id], ); const { data } = useApiMetadataQuery(queryKey, queryFn, queryOptions); diff --git a/src/core_modules/capture-core/components/Pages/EnrollmentAddEvent/EnrollmentAddEventPageDefault/EnrollmentAddEventPageDefault.component.js b/src/core_modules/capture-core/components/Pages/EnrollmentAddEvent/EnrollmentAddEventPageDefault/EnrollmentAddEventPageDefault.component.js index 01fc09eae1..1e3b7b907a 100644 --- a/src/core_modules/capture-core/components/Pages/EnrollmentAddEvent/EnrollmentAddEventPageDefault/EnrollmentAddEventPageDefault.component.js +++ b/src/core_modules/capture-core/components/Pages/EnrollmentAddEvent/EnrollmentAddEventPageDefault/EnrollmentAddEventPageDefault.component.js @@ -4,7 +4,6 @@ import i18n from '@dhis2/d2-i18n'; import { spacersNum } from '@dhis2/ui'; import withStyles from '@material-ui/core/styles/withStyles'; import type { Props } from './EnrollmentAddEventPageDefault.types'; -import { IncompleteSelectionsMessage } from '../../../IncompleteSelectionsMessage'; import { EnrollmentPageLayout } from '../../common/EnrollmentOverviewDomain/EnrollmentPageLayout'; import { EnrollmentPageKeys, @@ -65,14 +64,6 @@ const EnrollmentAddEventPagePain = ({ ); } - if (!orgUnitId) { - return ( - - {i18n.t('Choose an organisation unit to start reporting')} - - ); - } - if (!ready) { return null; } diff --git a/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/DataEntry/dataEntry.types.js b/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/DataEntry/dataEntry.types.js index 7935f96379..0c8c433cee 100644 --- a/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/DataEntry/dataEntry.types.js +++ b/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/DataEntry/dataEntry.types.js @@ -6,7 +6,7 @@ import type { RulesExecutionDependenciesClientFormatted } from '../common.types' export type ContainerProps = {| stage: ProgramStage, formFoundation: RenderFoundation, - orgUnit: OrgUnit, + orgUnit?: OrgUnit, id: string, itemId: string, formRef: (formInstance: any) => void, diff --git a/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/DataEntry/helpers/getOpenDataEntryActions.js b/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/DataEntry/helpers/getOpenDataEntryActions.js index 2dc83e03da..f372d1cc69 100644 --- a/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/DataEntry/helpers/getOpenDataEntryActions.js +++ b/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/DataEntry/helpers/getOpenDataEntryActions.js @@ -43,10 +43,8 @@ const dataEntryPropsToInclude: DataEntryPropsToInclude = [ export const getOpenDataEntryActions = (dataEntryId: string, itemId: string, programCategory?: ProgramCategory, orgUnit: Object) => { - const { id, name, path } = orgUnit; - const defaultDataEntryValues = { - orgUnit: { id, name, path }, - }; + const { id, name, path } = orgUnit || {}; + const defaultDataEntryValues = { id, name, path }; if (programCategory && programCategory.categories) { dataEntryPropsToInclude.push(...programCategory.categories.map(category => ({ id: `attributeCategoryOptions-${category.id}`, diff --git a/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/OrgUnitFetcher/OrgUnitFetcher.component.js b/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/OrgUnitFetcher/OrgUnitFetcher.component.js index f92ecbfa41..e6ab9c974c 100644 --- a/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/OrgUnitFetcher/OrgUnitFetcher.component.js +++ b/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/OrgUnitFetcher/OrgUnitFetcher.component.js @@ -19,14 +19,10 @@ export const OrgUnitFetcher = ({ ); } - if (orgUnit) { - return ( - - ); - } - - return null; + return ( + + ); }; diff --git a/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/SavingText/savingText.types.js b/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/SavingText/savingText.types.js index 90b4edcc85..ad3ca4d9b3 100644 --- a/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/SavingText/savingText.types.js +++ b/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/SavingText/savingText.types.js @@ -1,7 +1,7 @@ // @flow export type Props = {| - orgUnitName: string, + orgUnitName?: string, stageName: string, programName: string, |}; diff --git a/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/Validated/Validated.component.js b/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/Validated/Validated.component.js index b3ba7c2d14..724df8ab7e 100644 --- a/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/Validated/Validated.component.js +++ b/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/Validated/Validated.component.js @@ -61,7 +61,7 @@ const ValidatedPlain = ({ cancelButtonIsDisabled={eventSaveInProgress} id={id} /> - + )} diff --git a/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/Validated/Validated.container.js b/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/Validated/Validated.container.js index 61c961a257..b5d03ddaf4 100644 --- a/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/Validated/Validated.container.js +++ b/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/Validated/Validated.container.js @@ -49,8 +49,6 @@ export const Validated = ({ dataEntryId, itemId, programId: program.id, - orgUnitId: orgUnit.id, - orgUnitName: orgUnit.name, teiId, enrollmentId, formFoundation, @@ -137,7 +135,7 @@ export const Validated = ({ dispatch(startCreateNewAfterCompleting({ enrollmentId, isCreateNew, - orgUnitId: orgUnit.id, + orgUnitId: orgUnit?.id, programId: program.id, teiId, availableProgramStages, @@ -145,7 +143,7 @@ export const Validated = ({ } catch (error) { // Related stages has displayed an error message. No need to do anything here. } - }, [handleSave, formFoundation, dispatch, enrollmentId, orgUnit.id, program.id, teiId, availableProgramStages]); + }, [handleSave, formFoundation, dispatch, enrollmentId, orgUnit?.id, program.id, teiId, availableProgramStages]); const handleSaveAndCompleteEnrollment = useCallback( @@ -177,7 +175,7 @@ export const Validated = ({ stage={stage} allowGenerateNextVisit={stage.allowGenerateNextVisit} askCompleteEnrollmentOnEventComplete={stage.askCompleteEnrollmentOnEventComplete} - selectedOrgUnitId={orgUnit.id} + selectedOrgUnitId={orgUnit?.id} availableProgramStages={availableProgramStages} eventSaveInProgress={eventSaveInProgress} ready={ready} diff --git a/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/Validated/useBuildNewEventPayload.js b/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/Validated/useBuildNewEventPayload.js index ac81170a09..5b01cdf057 100644 --- a/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/Validated/useBuildNewEventPayload.js +++ b/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/Validated/useBuildNewEventPayload.js @@ -12,11 +12,9 @@ import type { LinkedRequestEvent, RelatedStageRefPayload, RequestEvent } from '. type Props = { dataEntryId: string, itemId: string, - orgUnitId: string, programId: string, formFoundation: RenderFoundation, enrollmentId: string, - orgUnitName: string, teiId: string, }; diff --git a/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/Validated/useLifecycle.js b/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/Validated/useLifecycle.js index cd7106d38a..f081b90304 100644 --- a/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/Validated/useLifecycle.js +++ b/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/Validated/useLifecycle.js @@ -24,7 +24,7 @@ export const useLifecycle = ({ program: TrackerProgram, stage: ProgramStage, formFoundation: RenderFoundation, - orgUnit: OrgUnit, + orgUnit?: OrgUnit, dataEntryId: string, itemId: string, rulesExecutionDependenciesClientFormatted: RulesExecutionDependenciesClientFormatted, @@ -39,12 +39,12 @@ export const useLifecycle = ({ useEffect(() => { if (!isLoading) { dispatch(batchActions([ - ...getOpenDataEntryActions(dataEntryId, itemId, programCategory, orgUnit), + ...getOpenDataEntryActions(dataEntryId, itemId, programCategory), ])); dataEntryReadyRef.current = true; delayRulesExecutionRef.current = true; } - }, [dispatch, dataEntryId, itemId, program, formFoundation, isLoading, programCategory, orgUnit]); + }, [dispatch, dataEntryId, itemId, program, formFoundation, isLoading, programCategory]); const eventsRef = useRef(); const attributesRef = useRef(); @@ -55,7 +55,7 @@ export const useLifecycle = ({ // Refactor the helper methods (getCurrentClientValues, getCurrentClientMainData in rules/actionsCreator) to be more explicit with the arguments. const state = useSelector(stateArg => stateArg); useEffect(() => { - if (isLoading) { return; } + if (isLoading || !orgUnit) { return; } if (delayRulesExecutionRef.current) { // getRulesActions depends on settings in the redux store that are being managed through getOpenDataEntryActions. // The purpose of the following lines of code is to make sure the redux store is ready before calling getRulesActions. @@ -96,9 +96,12 @@ export const useLifecycle = ({ ]); const rulesReady = + (!orgUnit) || + ( eventsRef.current === eventsRulesDependency && attributesRef.current === attributesValuesRulesDependency && - enrollmentDataRef.current === enrollmentDataRulesDependency; + enrollmentDataRef.current === enrollmentDataRulesDependency + ); return dataEntryReadyRef.current && rulesReady; }; diff --git a/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/Validated/validated.types.js b/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/Validated/validated.types.js index e0af3da0ff..2dda46426b 100644 --- a/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/Validated/validated.types.js +++ b/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/Validated/validated.types.js @@ -40,7 +40,7 @@ export type RelatedStageRefPayload = {| export type ContainerProps = {| ...CommonValidatedProps, - orgUnit: OrgUnit, + orgUnit?: OrgUnit, |}; export type Props = {| @@ -50,7 +50,7 @@ export type Props = {| eventSaveInProgress: boolean, stage: ProgramStage, formFoundation: RenderFoundation, - orgUnit: OrgUnit, + orgUnit?: OrgUnit, ready: boolean, id: string, itemId: string,