Skip to content

Commit

Permalink
Add not found page and incident message (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
myty authored Dec 28, 2022
1 parent 0c25a81 commit 26b7b60
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ export function IncidentDetail() {

useAppLayout(
() => ({
pageBgStyle: "bg-white",
pageBgStyle: "bg-gray-100",
headerLeft: (
<PageTitle
onBack={handleGoBack}
showShareButton={webShare.enabled}
showShareButton={webShare.enabled && incident != null}
onShare={handleShare}
>
{getTitle(incident)}
Expand All @@ -33,17 +33,23 @@ export function IncidentDetail() {
[incident]
);

if (incident == null) {
return (
<>
<div className="grid h-full grid-cols-1 place-content-center">
<p className="px-10 text-center">
This incident cannot be found or is no longer active.
</p>
</div>
</>
);
}

return <IncidentDetailContent incident={incident} />;
}

function getTitle(incident?: IncidentRecord | null): string {
const { type } = incident ?? {};

if (type) {
return type;
}

return "Incident";
return incident?.type ?? "Not Found";
}

function getShareData(incident?: IncidentRecord | null) {
Expand Down
25 changes: 25 additions & 0 deletions src/lanco-incidents-app/src/pages/not-found.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from "react";
import { useNavigate } from "react-router-dom";
import PageTitle from "components/page-title";
import { useAppLayout } from "containers/app-layout";

export function NotFound() {
const navigate = useNavigate();
const handleGoBack = () => navigate("/", { replace: true });

useAppLayout(
() => ({
pageBgStyle: "bg-white",
headerLeft: <PageTitle onBack={handleGoBack}>Not Found</PageTitle>,
}),
[]
);

return (
<>
<div className="grid h-full grid-cols-1 place-content-center">
<p className="px-10 text-center">Page not found.</p>
</div>
</>
);
}
5 changes: 4 additions & 1 deletion src/lanco-incidents-app/src/router.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from "react";
import Home from "pages/home";
import { createBrowserRouter } from "react-router-dom";
import { createBrowserRouter, Navigate } from "react-router-dom";
import Settings from "pages/settings";
import { IncidentDetail } from "pages/incident-detail/incident-detail";
import AppLayout from "containers/app-layout";
import { NotFound } from "pages/not-found";

export const router = createBrowserRouter([
{
Expand All @@ -22,6 +23,8 @@ export const router = createBrowserRouter([
path: "incidents/:id",
element: <IncidentDetail />,
},
{ path: "/not-found", element: <NotFound /> },
{ path: "*", element: <Navigate to="not-found" /> },
],
},
]);

1 comment on commit 26b7b60

@vercel
Copy link

@vercel vercel bot commented on 26b7b60 Dec 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.