Skip to content

Commit

Permalink
Merge pull request #507 from NYPL/SFR-1944/add-error-handling-read-page
Browse files Browse the repository at this point in the history
SFR-1944: Add error handling for invalid read data
  • Loading branch information
jackiequach authored Jul 18, 2024
2 parents a6b39f5 + 83e489c commit bc89c72
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- SFR-2008: Automate License Page Headers and Sub-Headers
- SFR-2033: Verify the external NYPL header links of DRB App
- Update PR template with new Jira link
- Add error page for /read links with invalid source

## [0.18.1]

Expand Down
5 changes: 5 additions & 0 deletions src/components/ReaderLayout/ReaderLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import Link from "../Link/Link";
import { addTocToManifest } from "@nypl/web-reader";
import Loading from "../Loading/Loading";
import { trackCtaClick } from "~/src/lib/adobe/Analytics";
import NotFound404 from "~/src/pages/404";

const origin =
typeof window !== "undefined" && window.location?.origin
Expand Down Expand Up @@ -148,6 +149,10 @@ const ReaderLayout: React.FC<{
);
};

if (!isEmbed && !isRead) {
return NotFound404();
}

return (
<>
{isEmbed && (
Expand Down
37 changes: 25 additions & 12 deletions src/pages/404.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
import { TemplateAppContainer } from "@nypl/design-system-react-components";
import React from "react";
import DrbBreakout from "../components/DrbBreakout/DrbBreakout";
import Layout from "../components/Layout/Layout";
import Link from "../components/Link/Link";

const NotFound404 = () => (
<Layout>
<h1>404 Not Found</h1>
const NotFound404 = () => {
const contentPrimaryElement = (
<>
<h1>404 Not Found</h1>

<p>We&apos;re sorry...</p>
<p>We&apos;re sorry...</p>

<p>The page you were looking for doesn&apos;t exist.</p>
<p>The page you were looking for doesn&apos;t exist.</p>

<p>
Search&nbsp;
<Link to="/">Digital Research Books Beta</Link>
{"."}
</p>
</Layout>
);
<p>
Search&nbsp;
<Link to="/">Digital Research Books Beta</Link>
{"."}
</p>
</>
);

return (
<Layout>
<TemplateAppContainer
breakout={<DrbBreakout />}
contentPrimary={contentPrimaryElement}
/>
</Layout>
);
};

export default NotFound404;

0 comments on commit bc89c72

Please sign in to comment.