From ab08e00faa7887de8583a5ff412820b3d26e819f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Storl=C3=B8kken=20Melseth?= Date: Tue, 3 Oct 2023 16:44:47 +0200 Subject: [PATCH] fix: bugs --- .../RecentlyAddedEventsList.component.js | 6 ++-- .../Pages/MainPage/MainPage.container.js | 28 +++++++++++++------ 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/core_modules/capture-core/components/DataEntries/SingleEventRegistrationEntry/DataEntryWrapper/RecentlyAddedEventsList/RecentlyAddedEventsList.component.js b/src/core_modules/capture-core/components/DataEntries/SingleEventRegistrationEntry/DataEntryWrapper/RecentlyAddedEventsList/RecentlyAddedEventsList.component.js index 0a66c352ad..f21aa0c714 100644 --- a/src/core_modules/capture-core/components/DataEntries/SingleEventRegistrationEntry/DataEntryWrapper/RecentlyAddedEventsList/RecentlyAddedEventsList.component.js +++ b/src/core_modules/capture-core/components/DataEntries/SingleEventRegistrationEntry/DataEntryWrapper/RecentlyAddedEventsList/RecentlyAddedEventsList.component.js @@ -27,10 +27,12 @@ const styles = (theme: Theme) => ({ const NewEventsList = (props: Props) => { const { classes, ...passOnProps } = props; const { push } = useHistory(); - const eventsAdded = props.events ? Object.keys(props.events).length : 0; - if (eventsAdded === 0) { + + if (!props.events || !Object.keys(props.events).length) { return null; } + const eventsAdded = Object.keys(props.events).length - 1; + return (
({ - currentSelectionsComplete: !!state.currentSelections.complete, - programId: state.currentSelections.programId, - error: state.activePage.selectionsError && state.activePage.selectionsError.error, // TODO: Should probably remove this - ready: !state.activePage.lockedSelectorLoads, // TODO: Should probably remove this -}); +const WrappedMainPage = withLoadingIndicator()(withErrorMessageHandler()(MainPageComponent)); -// $FlowFixMe[missing-annot] automated comment -export const MainPage = connect(mapStateToProps)(withLoadingIndicator()(withErrorMessageHandler()(MainPageComponent))); +export const MainPage = (props) => { + const currentSelectionsComplete = useSelector(({ currentSelections }) => !!currentSelections.complete); + const programId = useSelector(({ currentSelections }) => currentSelections.programId); + const error = useSelector(({ activePage }) => activePage.selectionsError && activePage.selectionsError.error); + const ready = useSelector(({ activePage }) => !activePage.lockedSelectorLoads); + + return ( + + ); +};