diff --git a/.changeset/not-found-page.md b/.changeset/not-found-page.md new file mode 100644 index 0000000..d0043f8 --- /dev/null +++ b/.changeset/not-found-page.md @@ -0,0 +1,5 @@ +--- +"web": minor +--- + +A 404 page for dead links: the logo's box opened and empty, a one-click proof link when the path carries an order number, and an order lookup for anyone holding a label. diff --git a/apps/web/src/App.tsx b/apps/web/src/App.tsx index ee0528c..e3be9fe 100644 --- a/apps/web/src/App.tsx +++ b/apps/web/src/App.tsx @@ -1,6 +1,7 @@ import { useAuth } from "@workos-inc/authkit-react"; import { lazy, Suspense, useEffect } from "react"; +import { NotFoundPage } from "@/components/not-found-page"; import { PackingStation } from "@/components/packing-station"; import { SignInScreen } from "@/components/sign-in-screen"; import { ProofPage } from "@/proof/proof-page"; @@ -61,6 +62,10 @@ export function App() { return ; } + // "/" is also where WorkOS returns after sign-in; every other path is a dead link + const { pathname } = window.location; + if (pathname !== "/" && pathname !== "/login") return ; + if (isLoading) return ; if (!user) return signIn()} />; diff --git a/apps/web/src/components/not-found-page.tsx b/apps/web/src/components/not-found-page.tsx new file mode 100644 index 0000000..f0f6940 --- /dev/null +++ b/apps/web/src/components/not-found-page.tsx @@ -0,0 +1,136 @@ +import { ArrowRightIcon, PackageSearchIcon } from "lucide-react"; +import { useState } from "react"; + +import { Button } from "@/components/ui/button"; +import { Input } from "@/components/ui/input"; + +const proofHref = (orderId: string) => `/proof/${encodeURIComponent(orderId)}`; + +// A mistyped proof link usually still carries the order number, e.g. /proofs/PB-1001 or /pb1001 +function orderInPath(pathname: string) { + const match = /pb-?(\d+)/i.exec(pathname); + return match ? `PB-${match[1]}` : null; +} + +// The logo's cube with the lid open and nothing inside; side faces are the mark's own paths +function EmptyBox({ className }: { className?: string }) { + return ( + + + + + + + + + + + + + + + ); +} + +export function NotFoundPage({ pathname }: { pathname: string }) { + const [orderId, setOrderId] = useState(""); + const guess = orderInPath(pathname); + + return ( +
+
+ + ProofBox + +
+
+
+ 4 + + 4 +
+

+ This box is empty +

+

+ Nothing is packed at{" "} + {pathname}. The link may be + mistyped, or the page has moved. +

+ + {guess && ( + + )} + +
{ + event.preventDefault(); + const trimmed = orderId.trim(); + if (trimmed) window.location.assign(proofHref(trimmed)); + }} + > + +
+ setOrderId(event.target.value)} + placeholder="PB-1001" + autoCapitalize="characters" + autoComplete="off" + spellCheck={false} + className="h-9 font-mono" + /> + +
+
+ + + Back to ProofBox + +
+
+ ); +} diff --git a/apps/web/src/debug/state-gallery.tsx b/apps/web/src/debug/state-gallery.tsx index 5903c45..99e97bc 100644 --- a/apps/web/src/debug/state-gallery.tsx +++ b/apps/web/src/debug/state-gallery.tsx @@ -5,6 +5,7 @@ import { type Account, UserMenu } from "@/components/app-header"; import { ThemeSwitch } from "@/components/theme-switch"; import { CameraPanel } from "@/components/camera-panel"; import { type Preview, PreviewFrame, type PrintJob, PrintFeedback } from "@/components/label-panel"; +import { NotFoundPage } from "@/components/not-found-page"; import { OfflineBanner, PackingStation } from "@/components/packing-station"; import { PackHud } from "@/components/pack-panel"; import { PanelBoundary } from "@/components/panel-boundary"; @@ -434,6 +435,18 @@ export default function StateGallery() { +
+ +
+ +
+
+ +
+ +
+
+