Skip to content

Commit

Permalink
show not found page for invalid links
Browse files Browse the repository at this point in the history
  • Loading branch information
aimane-chnaif committed Nov 24, 2022
1 parent 652c147 commit 6b59d5e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/SCREENS.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ export default {
HOME: 'Home',
LOADING: 'Loading',
REPORT: 'Report',
NOT_FOUND: 'NotFound',
TRANSITION_FROM_OLD_DOT: 'TransitionFromOldDot',
};
3 changes: 2 additions & 1 deletion src/components/BlockingViews/FullPageNotFoundView.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const propTypes = {
...withLocalizePropTypes,

/** Child elements */
children: PropTypes.node.isRequired,
children: PropTypes.node,

/** If true, child components are replaced with a blocking "not found" view */
shouldShow: PropTypes.bool,
Expand All @@ -36,6 +36,7 @@ const propTypes = {
};

const defaultProps = {
children: null,
shouldShow: false,
titleKey: 'notFound.notHere',
subtitleKey: 'notFound.pageNotFound',
Expand Down
7 changes: 7 additions & 0 deletions src/libs/Navigation/AppNavigator/AuthScreens.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import * as User from '../../actions/User';
import * as Modal from '../../actions/Modal';
import modalCardStyleInterpolator from './modalCardStyleInterpolator';
import createCustomModalStackNavigator from './createCustomModalStackNavigator';
import NotFoundPage from '../../../pages/ErrorPage/NotFoundPage';

// Modal Stack Navigators
import * as ModalStackNavigators from './ModalStackNavigators';
Expand Down Expand Up @@ -314,6 +315,12 @@ class AuthScreens extends React.Component {
component={ModalStackNavigators.WalletStatementStackNavigator}
listeners={modalScreenListeners}
/>
<RootStack.Screen
name={SCREENS.NOT_FOUND}
options={{headerShown: false}}
component={NotFoundPage}
listeners={modalScreenListeners}
/>
</RootStack.Navigator>
);
}
Expand Down
1 change: 1 addition & 0 deletions src/libs/Navigation/linkingConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ export default {
WalletStatement_Root: ROUTES.WALLET_STATEMENT_WITH_DATE,
},
},
[SCREENS.NOT_FOUND]: '*',
},
},
};
14 changes: 14 additions & 0 deletions src/pages/ErrorPage/NotFoundPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import ScreenWrapper from '../../components/ScreenWrapper';
import FullPageNotFoundView from '../../components/BlockingViews/FullPageNotFoundView';

// eslint-disable-next-line rulesdir/no-negated-variables
const NotFoundPage = () => (
<ScreenWrapper>
<FullPageNotFoundView shouldShow />
</ScreenWrapper>
);

NotFoundPage.displayName = 'NotFoundPage';

export default NotFoundPage;

0 comments on commit 6b59d5e

Please sign in to comment.