From 3274b4300fc7610ad96cb687f6d7a4c8664d4265 Mon Sep 17 00:00:00 2001 From: henrikmv Date: Mon, 9 Dec 2024 15:29:01 +0100 Subject: [PATCH] fix: fix map center point when no org unit --- i18n/en.pot | 7 ++-- .../FormFields/New/HOC/withCenterPoint.js | 9 ++++-- .../SavingText/SavingText.component.js | 7 ++-- .../WidgetEventSchedule.component.js | 32 ++++++++----------- .../WidgetEventSchedule.container.js | 17 ++++------ 5 files changed, 36 insertions(+), 36 deletions(-) diff --git a/i18n/en.pot b/i18n/en.pot index 260549b63e..6c9b6fc55c 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-12-08T13:28:49.327Z\n" -"PO-Revision-Date: 2024-12-08T13:28:49.327Z\n" +"POT-Creation-Date: 2024-12-09T14:19:09.122Z\n" +"PO-Revision-Date: 2024-12-09T14:19:09.122Z\n" msgid "Choose one or more dates..." msgstr "Choose one or more dates..." @@ -1270,6 +1270,9 @@ msgstr "organisation unit could not be retrieved. Please try again later." msgid "Saving to {{stageName}} for {{programName}} in {{orgUnitName}}" msgstr "Saving to {{stageName}} for {{programName}} in {{orgUnitName}}" +msgid "Saving to {{stageName}} for {{programName}}" +msgstr "Saving to {{stageName}} for {{programName}}" + msgid "program or stage is invalid" msgstr "program or stage is invalid" 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 96039d9168..04c542c051 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,10 @@ const convertToClientCoordinates = ({ coordinates, type }: { coordinates: any[], const getCenterPoint = (InnerComponent: ComponentType) => (props: Object) => { const { orgUnit, ...passOnProps } = props; - const [orgUnitKey, setOrgUnitKey] = useState(orgUnit?.id); + if (!orgUnit || !orgUnit.id) { + return {}} />; + } + const [orgUnitKey, setOrgUnitKey] = useState(orgUnit.id); const [shouldFetch, setShouldFetch] = useState(false); const queryKey = ['organisationUnit', 'geometry', orgUnitKey]; const queryFn = { @@ -28,8 +31,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/WidgetEnrollmentEventNew/SavingText/SavingText.component.js b/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/SavingText/SavingText.component.js index 14df486439..4c0db5aa17 100644 --- a/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/SavingText/SavingText.component.js +++ b/src/core_modules/capture-core/components/WidgetEnrollmentEventNew/SavingText/SavingText.component.js @@ -7,8 +7,11 @@ import type { Props } from './savingText.types'; export const SavingText = ({ orgUnitName, stageName, programName }: Props) => ( - {i18n.t('Saving to {{stageName}} for {{programName}} in {{orgUnitName}}', - { orgUnitName, stageName, programName, interpolation: { escapeValue: false } })} + {orgUnitName + ? i18n.t('Saving to {{stageName}} for {{programName}} in {{orgUnitName}}', + { orgUnitName, stageName, programName, interpolation: { escapeValue: false } }) + : i18n.t('Saving to {{stageName}} for {{programName}}', + { stageName, programName, interpolation: { escapeValue: false } })} ); diff --git a/src/core_modules/capture-core/components/WidgetEventSchedule/WidgetEventSchedule.component.js b/src/core_modules/capture-core/components/WidgetEventSchedule/WidgetEventSchedule.component.js index cb670228d5..11397b3b7d 100644 --- a/src/core_modules/capture-core/components/WidgetEventSchedule/WidgetEventSchedule.component.js +++ b/src/core_modules/capture-core/components/WidgetEventSchedule/WidgetEventSchedule.component.js @@ -59,7 +59,6 @@ const WidgetEventSchedulePlain = ({ setScheduledOrgUnit(undefined); }; - return ( -
- - -
- + + {programCategory && { - if (!scheduleDate && suggestedScheduleDate) { - setScheduleDate(suggestedScheduleDate); - } + if (!scheduleDate && suggestedScheduleDate) { setScheduleDate(suggestedScheduleDate); } }, [suggestedScheduleDate, scheduleDate]); useEffect(() => {