diff --git a/i18n/en.pot b/i18n/en.pot index 58ea419d37..33736f34cd 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: 2026-05-26T07:35:44.230Z\n" -"PO-Revision-Date: 2026-05-26T07:35:44.230Z\n" +"POT-Creation-Date: 2026-05-29T09:53:55.823Z\n" +"PO-Revision-Date: 2026-05-29T09:53:55.823Z\n" msgid "The application could not be loaded." msgstr "The application could not be loaded." @@ -2234,6 +2234,12 @@ msgstr "Error editing the event, the changes made were not saved" msgid "Error updating the Assignee" msgstr "Error updating the Assignee" +msgid "Could not save enrollment note" +msgstr "Could not save enrollment note" + +msgid "Could not save event note" +msgstr "Could not save event note" + msgid "There was an error fetching metadata" msgstr "There was an error fetching metadata" diff --git a/src/core_modules/capture-core/components/Pages/ViewEvent/Notes/viewEventNotes.epics.ts b/src/core_modules/capture-core/components/Pages/ViewEvent/Notes/viewEventNotes.epics.ts index 2b0fc3a0e7..6d37b8299b 100644 --- a/src/core_modules/capture-core/components/Pages/ViewEvent/Notes/viewEventNotes.epics.ts +++ b/src/core_modules/capture-core/components/Pages/ViewEvent/Notes/viewEventNotes.epics.ts @@ -67,7 +67,7 @@ export const addNoteForViewEventEpic = (action$: any, store: any, { fromClientDa }, storedBy: username, storedAt: fromClientDate(moment().toISOString()).getServerZonedISOString(), - clientId: uuid(), + clientId, }; return batchActions([ startSaveEventNote(eventId, serverData, state.currentSelections, clientNote.clientId), diff --git a/src/core_modules/capture-core/components/Pages/ViewEvent/ViewEventComponent/editEvent.actions.ts b/src/core_modules/capture-core/components/Pages/ViewEvent/ViewEventComponent/editEvent.actions.ts index 87177c8eaa..8e4ef15909 100644 --- a/src/core_modules/capture-core/components/Pages/ViewEvent/ViewEventComponent/editEvent.actions.ts +++ b/src/core_modules/capture-core/components/Pages/ViewEvent/ViewEventComponent/editEvent.actions.ts @@ -6,8 +6,6 @@ export const actionTypes = { EVENT_FROM_URL_RETRIEVED: 'EventFromUrlRetrievedForEditEvent', EVENT_FROM_URL_COULD_NOT_BE_RETRIEVED: 'EventFromUrlCouldNotBeRetrievedForEditEvent', ORG_UNIT_RETRIEVAL_FAILED_ON_URL_UPDATE: 'OrgUnitRetrievalFailedForEditEventOnUrlUpdate', - ADD_EVENT_NOTE: 'AddEventNote', - REMOVE_EVENT_NOTE: 'RemoveEventNote', }; export const eventFromUrlCouldNotBeRetrieved = (message: string) => @@ -18,9 +16,3 @@ export const eventFromUrlRetrieved = (eventContainer: any, orgUnit: OrgUnit, pre export const orgUnitCouldNotBeRetrievedOnUrlUpdate = (eventContainer: any) => actionCreator(actionTypes.ORG_UNIT_RETRIEVAL_FAILED_ON_URL_UPDATE)({ eventContainer }); - -export const addEventNote = (eventId: string, note: any) => - actionCreator(actionTypes.ADD_EVENT_NOTE)({ eventId, note }); - -export const removeEventNote = (eventId: string, noteClientId: string) => - actionCreator(actionTypes.REMOVE_EVENT_NOTE)({ eventId, noteClientId }); diff --git a/src/core_modules/capture-core/components/Pages/ViewEvent/ViewEventComponent/viewEvent.actions.ts b/src/core_modules/capture-core/components/Pages/ViewEvent/ViewEventComponent/viewEvent.actions.ts index a24712b319..88af3a7479 100644 --- a/src/core_modules/capture-core/components/Pages/ViewEvent/ViewEventComponent/viewEvent.actions.ts +++ b/src/core_modules/capture-core/components/Pages/ViewEvent/ViewEventComponent/viewEvent.actions.ts @@ -8,8 +8,6 @@ export const actionTypes = { ORG_UNIT_RETRIEVED_ON_URL_UPDATE: 'OrgUnitRetrievedForViewEventOnUrlUpdate', ORG_UNIT_RETRIEVAL_FAILED_ON_URL_UPDATE: 'OrgUnitRetrievalFailedForViewEventOnUrlUpdate', START_OPEN_EVENT_FOR_VIEW: 'StartOpenEventForView', - ADD_EVENT_NOTE: 'AddEventNoteForViewEvent', - REMOVE_EVENT_NOTE: 'RemoveEventNoteForViewEvent', UPDATE_WORKING_LIST_ON_BACK_TO_MAIN_PAGE: 'UpdateWorkingListOnBackToMainPageForViewEvent', NO_WORKING_LIST_UPDATE_NEEDED_ON_BACK_TO_MAIN_PAGE: 'NoWorkingListUpdateNeededOnBackToMainPageForViewEvent', START_GO_BACK_TO_MAIN_PAGE: 'StartGoBackToMainPageForViewEvent', @@ -49,12 +47,6 @@ export const orgUnitCouldNotBeRetrievedOnUrlUpdate = (eventContainer: any) => export const startOpenEventForView = (eventContainer: any, orgUnit: any) => actionCreator(actionTypes.START_OPEN_EVENT_FOR_VIEW)({ eventContainer, orgUnit }); -export const addEventNote = (eventId: string, note: any) => - actionCreator(actionTypes.ADD_EVENT_NOTE)({ eventId, note }); - -export const removeEventNote = (eventId: string, noteClientId: string) => - actionCreator(actionTypes.REMOVE_EVENT_NOTE)({ eventId, noteClientId }); - export const startGoBackToMainPage = (orgUnitId: string | null) => actionCreator(actionTypes.START_GO_BACK_TO_MAIN_PAGE)({ orgUnitId }); diff --git a/src/core_modules/capture-core/components/WidgetEnrollmentNote/WidgetEnrollmentNote.actions.ts b/src/core_modules/capture-core/components/WidgetEnrollmentNote/WidgetEnrollmentNote.actions.ts index 619f3bffc9..7ade3abd34 100644 --- a/src/core_modules/capture-core/components/WidgetEnrollmentNote/WidgetEnrollmentNote.actions.ts +++ b/src/core_modules/capture-core/components/WidgetEnrollmentNote/WidgetEnrollmentNote.actions.ts @@ -7,12 +7,12 @@ export const actionTypes = { START_ADD_NOTE_FOR_ENROLLMENT: 'StartAddNoteForEnrollment', NOTE_ADDED_FOR_ENROLLMENT: 'NoteAddedForEnrollment', ADD_ENROLLMENT_NOTE: 'AddEnrollmentNote', + REMOVE_ENROLLMENT_NOTE: 'RemoveEnrollmentNote', ADD_NOTE_FAILED_FOR_ENROLLMENT: 'AddNoteFailedForEnrollment', }; export const batchActionTypes = { ADD_NOTE_BATCH_FOR_ENROLLMENT: 'AddNoteBatchForEnrollment', - REMOVE_NOTE_BATCH_FOR_ENROLLMENT: 'RemoveNoteBatchForEnrollment', }; export const requestAddNoteForEnrollment = (enrollmentId: string, note: string) => @@ -40,3 +40,6 @@ export const startAddNoteForEnrollment = ( export const addEnrollmentNote = (enrollmentUid: string, note: Record) => actionCreator(actionTypes.ADD_ENROLLMENT_NOTE)({ enrollmentUid, note }); + +export const removeEnrollmentNote = (enrollmentUid: string, noteClientId: string) => + actionCreator(actionTypes.REMOVE_ENROLLMENT_NOTE)({ enrollmentUid, noteClientId }); diff --git a/src/core_modules/capture-core/components/WidgetEnrollmentNote/WidgetEnrollmentNote.epics.ts b/src/core_modules/capture-core/components/WidgetEnrollmentNote/WidgetEnrollmentNote.epics.ts index 609f3a200e..9b4a5b0272 100644 --- a/src/core_modules/capture-core/components/WidgetEnrollmentNote/WidgetEnrollmentNote.epics.ts +++ b/src/core_modules/capture-core/components/WidgetEnrollmentNote/WidgetEnrollmentNote.epics.ts @@ -6,7 +6,7 @@ import uuid from 'd2-utilizr/lib/uuid'; import moment from 'moment'; import type { ReduxStore, ApiUtils, EpicAction } from 'capture-core-utils/types/global'; import { CurrentUser } from '../../utils/userInfo/CurrentUser'; -import { actionTypes, batchActionTypes, startAddNoteForEnrollment, addEnrollmentNote } +import { actionTypes, batchActionTypes, startAddNoteForEnrollment, addEnrollmentNote, removeEnrollmentNote } from './WidgetEnrollmentNote.actions'; import type { ClientNote, SaveContext } from './WidgetEnrollmentNote.types'; @@ -47,6 +47,7 @@ export const addNoteForEnrollmentEpic = ( }, storedBy: username, storedAt: fromClientDate(moment().toISOString()).getServerZonedISOString(), + clientId, }; const saveContext: SaveContext = { @@ -59,3 +60,12 @@ export const addNoteForEnrollmentEpic = ( addEnrollmentNote(enrollmentId, clientNote), ], batchActionTypes.ADD_NOTE_BATCH_FOR_ENROLLMENT); })); + +export const removeNoteForEnrollmentEpic = ( + action$: EpicAction, +) => + action$.pipe( + ofType(actionTypes.ADD_NOTE_FAILED_FOR_ENROLLMENT), + map((action: { meta: { context: SaveContext } }) => + removeEnrollmentNote(action.meta.context.enrollmentId, action.meta.context.noteClientId), + )); diff --git a/src/core_modules/capture-core/components/WidgetEnrollmentNote/WidgetEnrollmentNote.types.ts b/src/core_modules/capture-core/components/WidgetEnrollmentNote/WidgetEnrollmentNote.types.ts index 4f3470de6e..4cc1e94307 100644 --- a/src/core_modules/capture-core/components/WidgetEnrollmentNote/WidgetEnrollmentNote.types.ts +++ b/src/core_modules/capture-core/components/WidgetEnrollmentNote/WidgetEnrollmentNote.types.ts @@ -7,6 +7,7 @@ export type ClientNote = { }; storedBy: string; storedAt: string; + clientId: string; }; export type SaveContext = { diff --git a/src/core_modules/capture-core/components/WidgetEnrollmentNote/index.ts b/src/core_modules/capture-core/components/WidgetEnrollmentNote/index.ts index 2076d9af43..f06eb07149 100644 --- a/src/core_modules/capture-core/components/WidgetEnrollmentNote/index.ts +++ b/src/core_modules/capture-core/components/WidgetEnrollmentNote/index.ts @@ -1 +1,2 @@ export { WidgetEnrollmentNote } from './WidgetEnrollmentNote.component'; +export { actionTypes as enrollmentNoteActionTypes } from './WidgetEnrollmentNote.actions'; diff --git a/src/core_modules/capture-core/components/WidgetEventNote/WidgetEventNote.actions.ts b/src/core_modules/capture-core/components/WidgetEventNote/WidgetEventNote.actions.ts index 3e91ecc142..7e62d9c502 100644 --- a/src/core_modules/capture-core/components/WidgetEventNote/WidgetEventNote.actions.ts +++ b/src/core_modules/capture-core/components/WidgetEventNote/WidgetEventNote.actions.ts @@ -11,7 +11,6 @@ export const actionTypes = { export const batchActionTypes = { ADD_NOTE_BATCH_FOR_EVENT: 'AddNoteBatchForEvent', - REMOVE_NOTE_BATCH_FOR_EVENT: 'RemoveNoteBatchForEvent', }; export const requestAddNoteForEvent = (itemId: string, dataEntryId: string, note: string) => diff --git a/src/core_modules/capture-core/components/WidgetEventNote/WidgetEventNote.epics.ts b/src/core_modules/capture-core/components/WidgetEventNote/WidgetEventNote.epics.ts index 9fca9c4e59..e37d3a81ae 100644 --- a/src/core_modules/capture-core/components/WidgetEventNote/WidgetEventNote.epics.ts +++ b/src/core_modules/capture-core/components/WidgetEventNote/WidgetEventNote.epics.ts @@ -7,12 +7,7 @@ import moment from 'moment'; import type { ReduxStore, ApiUtils, EpicAction } from 'capture-core-utils/types'; import { CurrentUser } from '../../utils/userInfo/CurrentUser'; import { actionTypes, batchActionTypes, startAddNoteForEvent } from './WidgetEventNote.actions'; -import type { ClientNote, FormNote, SaveContext } from './WidgetEventNote.types'; - -import { - addEventNote, - removeEventNote, -} from '../Pages/ViewEvent/ViewEventComponent/editEvent.actions'; +import type { FormNote, SaveContext } from './WidgetEventNote.types'; import { addNote, @@ -53,24 +48,16 @@ export const addNoteForEventEpic = ( const serverData = createServerData(eventId, payload.note, useNewEndpoint); - const clientNote: ClientNote = { + const formNote: FormNote = { value: payload.note, - lastUpdatedBy: { + createdBy: { firstName, surname, uid: clientId, }, storedBy: username, storedAt: fromClientDate(moment().toISOString()).getServerZonedISOString(), - }; - const formNote: FormNote = { - ...clientNote, - storedAt: clientNote.storedAt, - createdBy: { - firstName, - surname, - uid: clientId, - }, + clientId, }; const saveContext: SaveContext = { dataEntryId: payload.dataEntryId, @@ -82,7 +69,6 @@ export const addNoteForEventEpic = ( return batchActions([ startAddNoteForEvent(eventId, serverData, state.currentSelections, saveContext), addNote(payload.dataEntryId, payload.itemId, formNote), - addEventNote(eventId, clientNote), ], batchActionTypes.ADD_NOTE_BATCH_FOR_EVENT); })); @@ -91,8 +77,5 @@ export const removeNoteForEventEpic = (action$: EpicAction { const context = action.meta.context; - return batchActions([ - removeNote(context.dataEntryId, context.itemId, context.noteClientId), - removeEventNote(context.eventId, context.noteClientId), - ], batchActionTypes.REMOVE_NOTE_BATCH_FOR_EVENT); + return removeNote(context.dataEntryId, context.itemId, context.noteClientId); })); diff --git a/src/core_modules/capture-core/components/WidgetEventNote/WidgetEventNote.types.ts b/src/core_modules/capture-core/components/WidgetEventNote/WidgetEventNote.types.ts index 87957e6627..9331e9347e 100644 --- a/src/core_modules/capture-core/components/WidgetEventNote/WidgetEventNote.types.ts +++ b/src/core_modules/capture-core/components/WidgetEventNote/WidgetEventNote.types.ts @@ -3,23 +3,16 @@ export type Props = { dataEntryId: string; }; -export type ClientNote = { +export type FormNote = { value: string; - lastUpdatedBy: { + createdBy: { firstName: string; surname: string; uid: string; }; storedBy: string; storedAt: string; -}; - -export type FormNote = ClientNote & { - createdBy: { - firstName: string; - surname: string; - uid: string; - }; + clientId: string; }; export type SaveContext = { diff --git a/src/core_modules/capture-core/components/WidgetEventNote/index.ts b/src/core_modules/capture-core/components/WidgetEventNote/index.ts index df498109aa..009fe50208 100644 --- a/src/core_modules/capture-core/components/WidgetEventNote/index.ts +++ b/src/core_modules/capture-core/components/WidgetEventNote/index.ts @@ -1,2 +1,3 @@ export { WidgetEventNote } from './WidgetEventNote.component'; export { addNoteForEventEpic, removeNoteForEventEpic } from './WidgetEventNote.epics'; +export { actionTypes as eventNoteActionTypes } from './WidgetEventNote.actions'; diff --git a/src/core_modules/capture-core/reducers/descriptions/enrollmentDomain.reducerDescription.ts b/src/core_modules/capture-core/reducers/descriptions/enrollmentDomain.reducerDescription.ts index 42f057dbe8..ea63dd09ef 100644 --- a/src/core_modules/capture-core/reducers/descriptions/enrollmentDomain.reducerDescription.ts +++ b/src/core_modules/capture-core/reducers/descriptions/enrollmentDomain.reducerDescription.ts @@ -1,7 +1,6 @@ import { createReducerDescription } from '../../trackerRedux'; import { enrollmentSiteActionTypes } from '../../components/Pages/common/EnrollmentOverviewDomain'; -import { actionTypes as enrollmentNoteActionTypes } - from '../../components/WidgetEnrollmentNote/WidgetEnrollmentNote.actions'; +import { enrollmentNoteActionTypes } from '../../components/WidgetEnrollmentNote'; import { actionTypes as editEventActionTypes } from '../../components/WidgetEventEdit/EditEventDataEntry/editEventDataEntry.actions'; import { newEventWidgetActionTypes } from '../../components/WidgetEnrollmentEventNew/Validated/validated.actions'; @@ -260,6 +259,14 @@ export const enrollmentDomainDesc = createReducerDescription( notes: [...state.enrollment.notes, note], }, }), + [enrollmentNoteActionTypes.REMOVE_ENROLLMENT_NOTE]: + (state, { payload: { noteClientId } }) => ({ + ...state, + enrollment: { + ...state.enrollment, + notes: state.enrollment.notes.filter((n: any) => n?.clientId !== noteClientId), + }, + }), [editEventActionTypes.REQUEST_DELETE_EVENT_DATA_ENTRY]: (state, { payload: { eventId } }) => { const events = state.enrollment.events?.map((event) => { if (event.event === eventId) { diff --git a/src/core_modules/capture-core/reducers/descriptions/events.reducerDescription.ts b/src/core_modules/capture-core/reducers/descriptions/events.reducerDescription.ts index 24cc4d1cdb..88cf5bea3f 100644 --- a/src/core_modules/capture-core/reducers/descriptions/events.reducerDescription.ts +++ b/src/core_modules/capture-core/reducers/descriptions/events.reducerDescription.ts @@ -48,22 +48,6 @@ export const eventsDesc = createReducerDescription({ }; return newState; }, - [viewEventActionTypes.ADD_EVENT_NOTE]: (state, action) => { - const newState = { ...state }; - const payload = action.payload; - if (newState[payload.eventId]) { - newState[payload.eventId].notes = [...state[payload.eventId].notes, payload.note]; - } - return newState; - }, - [viewEventActionTypes.REMOVE_EVENT_NOTE]: (state, action) => { - const newState = { ...state }; - const payload = action.payload; - if (newState[payload.eventId]) { - newState[payload.eventId].notes = state[payload.eventId].notes.filter(n => n.clientId !== payload.noteClientId); - } - return newState; - }, }, 'events', {}); export const eventsValuesDesc = createReducerDescription({ diff --git a/src/core_modules/capture-core/reducers/descriptions/feedback.reducerDescriptionGetter.ts b/src/core_modules/capture-core/reducers/descriptions/feedback.reducerDescriptionGetter.ts index 781369f79d..e5e4cd7d09 100644 --- a/src/core_modules/capture-core/reducers/descriptions/feedback.reducerDescriptionGetter.ts +++ b/src/core_modules/capture-core/reducers/descriptions/feedback.reducerDescriptionGetter.ts @@ -28,6 +28,9 @@ import { registrationFormActionTypes } from '../../components/Pages/New/Registra import { enrollmentSiteActionTypes } from '../../components/Pages/common/EnrollmentOverviewDomain'; import { enrollmentEditEventActionTypes } from '../../components/Pages/EnrollmentEditEvent'; import { actionTypes as viewEventActionTypes } from '../../components/Pages/ViewEvent/ViewEventComponent/viewEvent.actions'; +import { enrollmentNoteActionTypes } from '../../components/WidgetEnrollmentNote'; +import { eventNoteActionTypes } from '../../components/WidgetEventNote'; +import { actionTypes as viewEventNotesActionTypes } from '../../components/Pages/ViewEvent/Notes/viewEventNotes.actions'; const alertVariants = { info: 'info', @@ -120,4 +123,10 @@ export const getFeedbackDesc = (appUpdaters: Updaters) => createReducerDescripti addErrorFeedback({ message: i18n.t('Error updating the Assignee') }), [enrollmentEditEventActionTypes.ASSIGNEE_SAVE_FAILED]: () => addErrorFeedback({ message: i18n.t('Error updating the Assignee') }), + [enrollmentNoteActionTypes.ADD_NOTE_FAILED_FOR_ENROLLMENT]: () => + addErrorFeedback({ message: i18n.t('Could not save enrollment note') }), + [eventNoteActionTypes.ADD_NOTE_FAILED_FOR_EVENT]: () => + addErrorFeedback({ message: i18n.t('Could not save event note') }), + [viewEventNotesActionTypes.SAVE_EVENT_NOTE_FAILED]: () => + addErrorFeedback({ message: i18n.t('Could not save event note') }), }, 'feedbacks', []); diff --git a/src/epics/trackerCapture.epics.ts b/src/epics/trackerCapture.epics.ts index 0b03a2f174..d99b8fb5d1 100644 --- a/src/epics/trackerCapture.epics.ts +++ b/src/epics/trackerCapture.epics.ts @@ -128,7 +128,9 @@ import { saveNoteForViewEventFailedEpic, } from 'capture-core/components/Pages/ViewEvent/Notes/viewEventNotes.epics'; -import { addNoteForEnrollmentEpic } from 'capture-core/components/WidgetEnrollmentNote/WidgetEnrollmentNote.epics'; +import { addNoteForEnrollmentEpic, + removeNoteForEnrollmentEpic, +} from 'capture-core/components/WidgetEnrollmentNote/WidgetEnrollmentNote.epics'; import { openNewRelationshipRegisterTeiEpic, loadSearchGroupDuplicatesForReviewEpic, @@ -374,6 +376,7 @@ export const epics = (combineEpics as any)( addNoteForNewEnrollmentEventEpic, addNoteForEnrollmentEpic, navigateToEnrollmentOverviewEpic, + removeNoteForEnrollmentEpic, scheduleEnrollmentEventEpic, orgUnitFetcherEpic, getCoreOrgUnitEpic,