Skip to content

Commit

Permalink
fix: view event breadcrumb item
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikmv committed Feb 7, 2025
1 parent 16580f1 commit 794a2a9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Props = {
programId: string,
userInteractionInProgress?: boolean,
onBackToMainPage?: () => void,
onBackToViewEvent?: () => void,
};

const styles = {
Expand All @@ -33,6 +34,7 @@ const EventBreadcrumbPlain = ({
page,
programId,
userInteractionInProgress,
onBackToViewEvent,
onBackToMainPage,
classes,
}) => {
Expand All @@ -57,7 +59,7 @@ const EventBreadcrumbPlain = ({
},
{
key: pageKeys.VIEW_EVENT,
onClick: () => handleNavigation(null, pageKeys.VIEW_EVENT),
onClick: () => handleNavigation(onBackToViewEvent, pageKeys.VIEW_EVENT),
label: i18n.t('View event'),
selected: page === pageKeys.VIEW_EVENT,
condition: page === pageKeys.VIEW_EVENT || page === pageKeys.EDIT_EVENT,
Expand All @@ -72,6 +74,7 @@ const EventBreadcrumbPlain = ({
].filter(item => item.condition !== false)), [
label,
handleNavigation,
onBackToViewEvent,
onBackToMainPage,
page,
]);
Expand All @@ -94,8 +97,20 @@ const EventBreadcrumbPlain = ({

<DiscardDialog
open={openWarning === pageKeys.MAIN_PAGE}
onDestroy={() => {
setOpenWarning(null);
onBackToMainPage && onBackToMainPage();
}}
onCancel={() => setOpenWarning(null)}
{...defaultDialogProps}
/>
<DiscardDialog
open={openWarning === pageKeys.VIEW_EVENT}
onDestroy={() => {
setOpenWarning(null);
onBackToViewEvent && onBackToViewEvent();
}}
onCancel={() => setOpenWarning(null)}
onDestroy={onBackToMainPage}
{...defaultDialogProps}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class ViewEventPlain extends Component<Props, State> {
<EventDetails
eventAccess={eventAccess}
programStage={programStage}
onBackToViewEvent={onBackToViewEvent}
onBackToAllEvents={onBackToAllEvents}
/>
<RightColumnWrapper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import { connect } from 'react-redux';
import { dataEntryIds, dataEntryKeys } from 'capture-core/constants';
import { rollbackAssignee, setAssignee, startGoBackToMainPage } from './viewEvent.actions';
import { cancelEditEventDataEntry } from '../../../WidgetEventEdit/EditEventDataEntry/editEventDataEntry.actions';
import { ViewEventComponent } from './ViewEvent.component';
import { getDataEntryKey } from '../../../DataEntry/common/getDataEntryKey';

import { withErrorMessageHandler } from '../../../../HOC/withErrorMessageHandler';
import {
makeAssignedUserContextSelector,
Expand Down Expand Up @@ -43,6 +43,9 @@ const mapDispatchToProps = (dispatch: ReduxDispatch) => ({
onBackToAllEvents: () => {
dispatch(startGoBackToMainPage());
},
onBackToViewEvent: () => {
dispatch(cancelEditEventDataEntry());
},
dispatch,
});

Expand Down

0 comments on commit 794a2a9

Please sign in to comment.