Skip to content

Commit

Permalink
fix: bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
JoakimSM committed Oct 3, 2023
1 parent c785a79 commit ab08e00
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Paper className={classes.container}>
<div
Expand Down
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}
/>
);
};

0 comments on commit ab08e00

Please sign in to comment.