diff --git a/src/Pim/index.tsx b/src/Pim/index.tsx index 1a20130..91b875a 100644 --- a/src/Pim/index.tsx +++ b/src/Pim/index.tsx @@ -126,8 +126,22 @@ const styles = (theme: any) => ({ }, }); +function PageNotFound() { + return ( + +

404 Page Not Found

+
+ ); +} + + const CollectionRoutes = withStyles(styles)(withRouter( class CollectionRoutesInner extends React.PureComponent { + + private itemUndefined(itemUid: string) { + return this.props.items[itemUid] === undefined; + } + public render() { const props = this.props; const { classes } = this.props; @@ -155,6 +169,9 @@ const CollectionRoutes = withStyles(styles)(withRouter( exact render={({ match }) => { const itemUid = decodeURIComponent(match.params.itemUid); + if (this.itemUndefined(itemUid)) { + return PageNotFound(); + } return ( {(itemUid in props.items) && @@ -175,53 +192,65 @@ const CollectionRoutes = withStyles(styles)(withRouter( ( - - - - )} + render={({ match }) => { + const paramItemUid = decodeURIComponent(match.params.itemUid); + if (this.itemUndefined(paramItemUid)) { + return PageNotFound(); + } + return ( + + + + ); + }} /> ( - -
- - - -
- -
- )} + render={({ match, history }) => { + const itemUid = decodeURIComponent(match.params.itemUid); + if (this.itemUndefined(itemUid)) { + return PageNotFound(); + } + return ( + +
+ + + +
+ +
+ ); + }} /> );