-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
23 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 19 additions & 9 deletions
28
src/core_modules/capture-core/components/Pages/MainPage/MainPage.container.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,24 @@ | ||
// @flow | ||
import { connect } from 'react-redux'; | ||
import React from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
import { MainPageComponent } from './MainPage.component'; | ||
import { withErrorMessageHandler, withLoadingIndicator } from '../../../HOC'; | ||
|
||
const mapStateToProps = (state: ReduxState) => ({ | ||
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 ( | ||
<WrappedMainPage | ||
currentSelectionsComplete={currentSelectionsComplete} | ||
programId={programId} | ||
error={error} | ||
ready={ready} | ||
{...props} | ||
/> | ||
); | ||
}; |