diff --git a/cypress/e2e/EnrollmentAddEventPage/EnrollmentAddEventPageForm/EnrollmentAddEventPageForm.js b/cypress/e2e/EnrollmentAddEventPage/EnrollmentAddEventPageForm/EnrollmentAddEventPageForm.js index f5369a15cf..ca8d21ed03 100644 --- a/cypress/e2e/EnrollmentAddEventPage/EnrollmentAddEventPageForm/EnrollmentAddEventPageForm.js +++ b/cypress/e2e/EnrollmentAddEventPage/EnrollmentAddEventPageForm/EnrollmentAddEventPageForm.js @@ -11,7 +11,7 @@ const changeEnrollmentAndEventsStatus = () => ( const enrollment = body.enrollments && body.enrollments.find(e => e.enrollment === 'FZAa7j0muDj'); const eventToDelete = enrollment.events.find(e => e.programStage === 'eHvTba5ijAh'); const { events, ...rest } = enrollment; - const enrollmentToUpdate = { ...rest, status: 'ACTIVE' }; + const enrollmentToUpdate = { ...rest, status: 'ACTIVE', completedAt: null, completedBy: null }; return cy .buildApiUrl('tracker?async=false&importStrategy=UPDATE') diff --git a/cypress/e2e/EnrollmentEditEventPage/EnrollmentEditEventPageForm/EnrollmentEditEventPageForm.js b/cypress/e2e/EnrollmentEditEventPage/EnrollmentEditEventPageForm/EnrollmentEditEventPageForm.js index bd8c7855fc..70468a3a93 100644 --- a/cypress/e2e/EnrollmentEditEventPage/EnrollmentEditEventPageForm/EnrollmentEditEventPageForm.js +++ b/cypress/e2e/EnrollmentEditEventPage/EnrollmentEditEventPageForm/EnrollmentEditEventPageForm.js @@ -13,7 +13,9 @@ const changeEnrollmentAndEventsStatus = () => ( const enrollmentToUpdate = { ...enrollment, status: 'ACTIVE', - events: [{ ...eventToUpdate, status: 'ACTIVE' }], + completedAt: null, + completedBy: null, + events: [{ ...eventToUpdate, status: 'ACTIVE', completedAt: null, completedBy: null }], }; return cy diff --git a/cypress/e2e/WidgetsForEnrollmentPages/WidgetEnrollment/index.js b/cypress/e2e/WidgetsForEnrollmentPages/WidgetEnrollment/index.js index fb01545e49..5303500a8d 100644 --- a/cypress/e2e/WidgetsForEnrollmentPages/WidgetEnrollment/index.js +++ b/cypress/e2e/WidgetsForEnrollmentPages/WidgetEnrollment/index.js @@ -13,8 +13,19 @@ const changeEnrollmentAndEventsStatus = () => ( .then(url => cy.request(url)) .then(({ body }) => { const enrollment = body.enrollments && body.enrollments.find(e => e.enrollment === 'qyx7tscVpVB'); - const eventsToUpdate = enrollment.events.map(e => ({ ...e, status: 'ACTIVE' })); - const enrollmentToUpdate = { ...enrollment, status: 'ACTIVE', events: eventsToUpdate }; + const eventsToUpdate = enrollment.events.map(e => ({ + ...e, + status: 'ACTIVE', + completedAt: null, + completedBy: null, + })); + const enrollmentToUpdate = { + ...enrollment, + status: 'ACTIVE', + completedAt: null, + completedBy: null, + events: eventsToUpdate, + }; return cy .buildApiUrl('tracker?async=false&importStrategy=UPDATE') diff --git a/src/core_modules/capture-core/components/WidgetEventEdit/EditEventDataEntry/editEventDataEntry.epics.js b/src/core_modules/capture-core/components/WidgetEventEdit/EditEventDataEntry/editEventDataEntry.epics.js index 217e656bf4..b2ee3da2e9 100644 --- a/src/core_modules/capture-core/components/WidgetEventEdit/EditEventDataEntry/editEventDataEntry.epics.js +++ b/src/core_modules/capture-core/components/WidgetEventEdit/EditEventDataEntry/editEventDataEntry.epics.js @@ -38,6 +38,7 @@ import { import { buildUrlQueryString } from '../../../utils/routing/buildUrlQueryString'; import { newEventWidgetActionTypes } from '../../WidgetEnrollmentEventNew/Validated/validated.actions'; import { enrollmentEditEventActionTypes } from '../../Pages/EnrollmentEditEvent'; +import { statusTypes } from '../../../events/statusTypes'; const getDataEntryId = (event): string => ( getScopeInfo(event?.programId)?.scopeType === scopeTypes.TRACKER_PROGRAM @@ -106,9 +107,13 @@ export const saveEditedEventEpic = (action$: InputObservable, store: ReduxStore, const formServerValues = formFoundation.convertValues(formClientValues, convertToServerValue); const mainDataServerValues: Object = convertMainEventClientToServer(mainDataClientValues, minor); - if (mainDataServerValues.status === 'COMPLETED' && !prevEventMainData.completedAt) { + if (mainDataServerValues.status === statusTypes.COMPLETED && !prevEventMainData.completedAt) { mainDataServerValues.completedAt = getFormattedStringFromMomentUsingEuropeanGlyphs(moment()); } + if (mainDataServerValues.status === statusTypes.ACTIVE) { + mainDataServerValues.completedAt = null; + mainDataServerValues.completedBy = null; + } const { eventContainer: prevEventContainer } = state.viewEventPage.loadedValues;