diff --git a/i18n/en.pot b/i18n/en.pot index 138a2722ee..0914cc6d61 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-10-30T11:27:59.565Z\n" -"PO-Revision-Date: 2024-10-30T11:27:59.565Z\n" +"POT-Creation-Date: 2024-10-30T12:38:53.423Z\n" +"PO-Revision-Date: 2024-10-30T12:38:53.423Z\n" msgid "Choose one or more dates..." msgstr "Choose one or more dates..." @@ -1489,6 +1489,9 @@ msgstr "{{ scheduledEvents }} scheduled" msgid "Stages and Events" msgstr "Stages and Events" +msgid "An error occurred while unlinking and deleting the event." +msgstr "An error occurred while unlinking and deleting the event." + msgid "" "Are you sure you want to unlink and delete the event? This will permanently " "remove the event and all related data." @@ -1496,9 +1499,6 @@ msgstr "" "Are you sure you want to unlink and delete the event? This will permanently " "remove the event and all related data." -msgid "There was a problem unlinking and deleting the event" -msgstr "There was a problem unlinking and deleting the event" - msgid "Yes, unlink and delete event" msgstr "Yes, unlink and delete event" @@ -1508,9 +1508,6 @@ msgstr "Unlink relationship" msgid "Are you sure you want to unlink this relationship?" msgstr "Are you sure you want to unlink this relationship?" -msgid "There was a problem unlinking the relationship" -msgstr "There was a problem unlinking the relationship" - msgid "Yes, unlink relationship" msgstr "Yes, unlink relationship" diff --git a/src/core_modules/capture-core/components/WidgetTwoEventWorkspace/OverflowMenu/Modal/UnlinkAndDeleteModal.js b/src/core_modules/capture-core/components/WidgetTwoEventWorkspace/OverflowMenu/Modal/UnlinkAndDeleteModal.js index 6f465f26be..7b755acb41 100644 --- a/src/core_modules/capture-core/components/WidgetTwoEventWorkspace/OverflowMenu/Modal/UnlinkAndDeleteModal.js +++ b/src/core_modules/capture-core/components/WidgetTwoEventWorkspace/OverflowMenu/Modal/UnlinkAndDeleteModal.js @@ -8,9 +8,9 @@ import { ModalActions, ModalContent, ModalTitle, - NoticeBox, } from '@dhis2/ui'; -import { useDataEngine } from '@dhis2/app-runtime'; +import log from 'loglevel'; +import { useDataEngine, useAlert } from '@dhis2/app-runtime'; import { useMutation, useQueryClient } from 'react-query'; import { ReactQueryAppNamespace } from 'capture-core/utils/reactQueryHelpers'; import type { Props } from './UnlinkAndDeleteModal.types'; @@ -22,6 +22,10 @@ export const UnlinkAndDeleteModal = ({ }: Props) => { const dataEngine = useDataEngine(); const queryClient = useQueryClient(); + const { show: showErrorAlert } = useAlert( + i18n.t('An error occurred while unlinking and deleting the event.'), + { critical: true }, + ); const deleteEvent = async () => { const mutation = { @@ -42,6 +46,13 @@ export const UnlinkAndDeleteModal = ({ ]); setOpenModal(false); }, + onError: (error) => { + showErrorAlert(); + log.error( + `Failed to unlink and delete event with ID: ${eventId}`, + error, + ); + }, }); return ( @@ -53,14 +64,6 @@ export const UnlinkAndDeleteModal = ({ 'Are you sure you want to unlink and delete the event? This will permanently remove the event and all related data.', )}

- {mutation.isError && ( - - {mutation.error?.message} - - )} diff --git a/src/core_modules/capture-core/components/WidgetTwoEventWorkspace/OverflowMenu/Modal/UnlinkModal.js b/src/core_modules/capture-core/components/WidgetTwoEventWorkspace/OverflowMenu/Modal/UnlinkModal.js index 50dae38ef7..a312126348 100644 --- a/src/core_modules/capture-core/components/WidgetTwoEventWorkspace/OverflowMenu/Modal/UnlinkModal.js +++ b/src/core_modules/capture-core/components/WidgetTwoEventWorkspace/OverflowMenu/Modal/UnlinkModal.js @@ -8,9 +8,9 @@ import { ModalActions, ButtonStrip, Button, - NoticeBox, } from '@dhis2/ui'; -import { useDataEngine } from '@dhis2/app-runtime'; +import log from 'loglevel'; +import { useDataEngine, useAlert } from '@dhis2/app-runtime'; import { useMutation, useQueryClient } from 'react-query'; import { ReactQueryAppNamespace } from 'capture-core/utils/reactQueryHelpers'; import type { Props } from './UnlinkModal.types'; @@ -22,6 +22,10 @@ export const UnlinkModal = ({ }: Props) => { const dataEngine = useDataEngine(); const queryClient = useQueryClient(); + const { show: showErrorAlert } = useAlert( + i18n.t('An error occurred while unlinking and deleting the event.'), + { critical: true }, + ); const deleteRelationship = async () => { const mutation = { @@ -42,6 +46,13 @@ export const UnlinkModal = ({ ]); setOpenModal(false); }, + onError: (error) => { + showErrorAlert(); + log.error( + `Failed to remove relationship with id ${relationshipId}`, + error, + ); + }, }); return ( @@ -51,14 +62,6 @@ export const UnlinkModal = ({

{i18n.t('Are you sure you want to unlink this relationship?')}

- {mutation.isError && ( - - {mutation.error?.message} - - )}