Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down Expand Up @@ -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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand All @@ -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 });
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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 });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down Expand Up @@ -40,3 +40,6 @@ export const startAddNoteForEnrollment = (

export const addEnrollmentNote = (enrollmentUid: string, note: Record<string, unknown>) =>
actionCreator(actionTypes.ADD_ENROLLMENT_NOTE)({ enrollmentUid, note });

export const removeEnrollmentNote = (enrollmentUid: string, noteClientId: string) =>
actionCreator(actionTypes.REMOVE_ENROLLMENT_NOTE)({ enrollmentUid, noteClientId });
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -47,6 +47,7 @@ export const addNoteForEnrollmentEpic = (
},
storedBy: username,
storedAt: fromClientDate(moment().toISOString()).getServerZonedISOString(),
clientId,
};

const saveContext: SaveContext = {
Expand All @@ -59,3 +60,12 @@ export const addNoteForEnrollmentEpic = (
addEnrollmentNote(enrollmentId, clientNote),
], batchActionTypes.ADD_NOTE_BATCH_FOR_ENROLLMENT);
}));

export const removeNoteForEnrollmentEpic = (
action$: EpicAction<unknown, { context: SaveContext }>,
) =>
action$.pipe(
ofType(actionTypes.ADD_NOTE_FAILED_FOR_ENROLLMENT),
map((action: { meta: { context: SaveContext } }) =>
removeEnrollmentNote(action.meta.context.enrollmentId, action.meta.context.noteClientId),
));
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export type ClientNote = {
};
storedBy: string;
storedAt: string;
clientId: string;
};

export type SaveContext = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { WidgetEnrollmentNote } from './WidgetEnrollmentNote.component';
export { actionTypes as enrollmentNoteActionTypes } from './WidgetEnrollmentNote.actions';
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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);
}));

Expand All @@ -91,8 +77,5 @@ export const removeNoteForEventEpic = (action$: EpicAction<any, RemoveNoteAction
ofType(actionTypes.ADD_NOTE_FAILED_FOR_EVENT),
map((action: { meta: { context: SaveContext } }) => {
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);
}));
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { WidgetEventNote } from './WidgetEventNote.component';
export { addNoteForEventEpic, removeNoteForEventEpic } from './WidgetEventNote.epics';
export { actionTypes as eventNoteActionTypes } from './WidgetEventNote.actions';
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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', []);
5 changes: 4 additions & 1 deletion src/epics/trackerCapture.epics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -374,6 +376,7 @@ export const epics = (combineEpics as any)(
addNoteForNewEnrollmentEventEpic,
addNoteForEnrollmentEpic,
navigateToEnrollmentOverviewEpic,
removeNoteForEnrollmentEpic,
scheduleEnrollmentEventEpic,
orgUnitFetcherEpic,
getCoreOrgUnitEpic,
Expand Down
Loading