Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

✨ Better 404 page (#2221)

Luke Vellaeccce179dc3b
diff --git a/apps/web/public/locales/en/app.json b/apps/web/public/locales/en/app.json
index b78a9761b..1019bc5f4 100644
--- a/apps/web/public/locales/en/app.json
+++ b/apps/web/public/locales/en/app.json
@@ -83,10 +83,8 @@
"you": "You",
"yourName": "Your name…",
"common_language": "Language",
- "common_support": "Support",
"errors_notFoundTitle": "404 not found",
"errors_notFoundDescription": "We couldn't find the page you're looking for.",
- "errors_goToHome": "Go to home",
"optionCount": "{count, plural, one {# option} other {# options}}",
"addComment": "Add Comment",
"profile": "Profile",
@@ -617,5 +615,8 @@
"errorLinkSupport": "Support",
"errorLinkSupportDescription": "Browse our help articles and FAQs.",
"errorLinkGithub": "GitHub",
- "errorLinkGithubDescription": "Report an issue or check for updates."
+ "errorLinkGithubDescription": "Report an issue or check for updates.",
+ "notFoundLabel": "404",
+ "notFoundTitle": "Page not found",
+ "notFoundDescription": "Sorry, we couldn't find the page you're looking for. Here are some helpful links instead."
}
diff --git a/apps/web/src/app/[locale]/error.tsx b/apps/web/src/app/[locale]/error.tsx
index d4af5778f..4d79ffe6e 100644
--- a/apps/web/src/app/[locale]/error.tsx
+++ b/apps/web/src/app/[locale]/error.tsx
@@ -2,54 +2,13 @@
import { Button } from "@rallly/ui/button";
import * as Sentry from "@sentry/nextjs";
-import {
- ChevronRightIcon,
- GithubIcon,
- HomeIcon,
- LifeBuoyIcon,
- PlusIcon,
-} from "lucide-react";
-import Image from "next/image";
+import { GithubIcon, HomeIcon, LifeBuoyIcon, PlusIcon } from "lucide-react";
import Link from "next/link";
import React from "react";
+import { ErrorPage, ErrorPageLinkItem } from "@/components/error-page";
import { Trans } from "@/i18n/client";
-function ErrorLinkItem({
- href,
- icon,
- title,
- description,
-}: {
- href: string;
- icon: React.ReactNode;
- title: React.ReactNode;
- description: React.ReactNode;
-}) {
- return (
- <li className="relative flex gap-x-6 py-6">
- <div className="flex size-10 flex-none items-center justify-center rounded-lg border border-border bg-card">
- {icon}
- </div>
- <div className="flex-auto">
- <h3 className="font-semibold text-foreground text-sm">
- <Link href={href}>
- <span aria-hidden="true" className="absolute inset-0" />
- {title}
- </Link>
- </h3>
- <p className="mt-1 text-muted-foreground text-sm/6">{description}</p>
- </div>
- <div className="flex-none self-center">
- <ChevronRightIcon
- aria-hidden="true"
- className="size-4 text-muted-foreground"
- />
- </div>
- </li>
- );
-}
-
export default function LocaleErrorBoundary({
error,
reset,
@@ -62,97 +21,72 @@ export default function LocaleErrorBoundary({
}, [error]);
return (
- <div className="bg-background">
- <main className="mx-auto w-full max-w-7xl px-6 pt-10 pb-16 sm:pb-24 lg:px-8">
- <Image
- src="/static/logo.svg"
- alt="Rallly"
- width={130}
- height={30}
- className="mx-auto dark:hidden"
- />
- <Image
- src="/static/logo-dark.svg"
- alt="Rallly"
- width={130}
- height={30}
- className="mx-auto hidden dark:block"
+ <ErrorPage
+ label={<Trans i18nKey="errorLabel" defaults="Error" />}
+ title={<Trans i18nKey="errorTitle" defaults="Something went wrong" />}
+ description={
+ <Trans
+ i18nKey="errorDescription"
+ defaults="An unexpected error occurred. Please try again or visit one of the pages below."
/>
- <div className="mx-auto mt-20 max-w-2xl text-center sm:mt-24">
- <p className="font-semibold text-base/8 text-primary">
- <Trans i18nKey="errorLabel" defaults="Error" />
- </p>
- <h1 className="mt-4 text-balance font-semibold text-5xl text-foreground tracking-tight sm:text-6xl">
- <Trans i18nKey="errorTitle" defaults="Something went wrong" />
- </h1>
- <p className="mt-6 text-pretty font-medium text-lg text-muted-foreground sm:text-xl/8">
- <Trans
- i18nKey="errorDescription"
- defaults="An unexpected error occurred. Please try again or visit one of the pages below."
- />
- </p>
- </div>
- <div className="mx-auto mt-16 flow-root max-w-lg sm:mt-20">
- <ul className="-mt-6 divide-y divide-border border-border border-b">
- <ErrorLinkItem
- href="/"
- icon={<HomeIcon className="size-4 text-muted-foreground" />}
- title={<Trans i18nKey="errorLinkHome" defaults="Home" />}
- description={
- <Trans
- i18nKey="errorLinkHomeDescription"
- defaults="Go back to your dashboard."
- />
- }
- />
- <ErrorLinkItem
- href="/new"
- icon={<PlusIcon className="size-4 text-muted-foreground" />}
- title={
- <Trans i18nKey="errorLinkCreatePoll" defaults="Create a Poll" />
- }
- description={
- <Trans
- i18nKey="errorLinkCreatePollDescription"
- defaults="Start scheduling a new meeting."
- />
- }
- />
- <ErrorLinkItem
- href="https://support.rallly.co"
- icon={<LifeBuoyIcon className="size-4 text-muted-foreground" />}
- title={<Trans i18nKey="errorLinkSupport" defaults="Support" />}
- description={
- <Trans
- i18nKey="errorLinkSupportDescription"
- defaults="Browse our help articles and FAQs."
- />
- }
- />
- <ErrorLinkItem
- href="https://github.com/lukevella/rallly"
- icon={<GithubIcon className="size-4 text-muted-foreground" />}
- title={<Trans i18nKey="errorLinkGithub" defaults="GitHub" />}
- description={
- <Trans
- i18nKey="errorLinkGithubDescription"
- defaults="Report an issue or check for updates."
- />
- }
- />
- </ul>
- <div className="mt-10 flex items-center justify-center gap-x-4">
- <Button variant="primary" onClick={() => reset()}>
- <Trans i18nKey="errorTryAgain" defaults="Try again" />
- </Button>
- <Button asChild>
- <Link href="/">
- <Trans i18nKey="errorBackToHome" defaults="Back to home" />
- </Link>
- </Button>
- </div>
- </div>
- </main>
- </div>
+ }
+ actions={
+ <>
+ <Button variant="primary" onClick={() => reset()}>
+ <Trans i18nKey="errorTryAgain" defaults="Try again" />
+ </Button>
+ <Button asChild>
+ <Link href="/">
+ <Trans i18nKey="errorBackToHome" defaults="Back to home" />
+ </Link>
+ </Button>
+ </>
+ }
+ >
+ <ErrorPageLinkItem
+ href="/"
+ icon={<HomeIcon className="size-4 text-muted-foreground" />}
+ title={<Trans i18nKey="errorLinkHome" defaults="Home" />}
+ description={
+ <Trans
+ i18nKey="errorLinkHomeDescription"
+ defaults="Go back to your dashboard."
+ />
+ }
+ />
+ <ErrorPageLinkItem
+ href="/new"
+ icon={<PlusIcon className="size-4 text-muted-foreground" />}
+ title={<Trans i18nKey="errorLinkCreatePoll" defaults="Create a Poll" />}
+ description={
+ <Trans
+ i18nKey="errorLinkCreatePollDescription"
+ defaults="Start scheduling a new meeting."
+ />
+ }
+ />
+ <ErrorPageLinkItem
+ href="https://support.rallly.co"
+ icon={<LifeBuoyIcon className="size-4 text-muted-foreground" />}
+ title={<Trans i18nKey="errorLinkSupport" defaults="Support" />}
+ description={
+ <Trans
+ i18nKey="errorLinkSupportDescription"
+ defaults="Browse our help articles and FAQs."
+ />
+ }
+ />
+ <ErrorPageLinkItem
+ href="https://github.com/lukevella/rallly"
+ icon={<GithubIcon className="size-4 text-muted-foreground" />}
+ title={<Trans i18nKey="errorLinkGithub" defaults="GitHub" />}
+ description={
+ <Trans
+ i18nKey="errorLinkGithubDescription"
+ defaults="Report an issue or check for updates."
+ />
+ }
+ />
+ </ErrorPage>
);
}
diff --git a/apps/web/src/app/[locale]/not-found.tsx b/apps/web/src/app/[locale]/not-found.tsx
index 24f685b24..194f0bf8b 100644
--- a/apps/web/src/app/[locale]/not-found.tsx
+++ b/apps/web/src/app/[locale]/not-found.tsx
@@ -1,41 +1,63 @@
import { Button } from "@rallly/ui/button";
-import { FileSearchIcon } from "lucide-react";
+import { GithubIcon, HomeIcon, LifeBuoyIcon, PlusIcon } from "lucide-react";
import Link from "next/link";
+import { ErrorPage, ErrorPageLinkItem } from "@/components/error-page";
import { getTranslation } from "@/i18n/server";
-export default async function Page() {
+export default async function NotFoundPage() {
// TODO (Luke Vella) [2023-11-03]: not-found doesn't have access to params right now
// See: https://github.com/vercel/next.js/discussions/43179
const { t } = await getTranslation("en");
return (
- <div className="flex h-screen w-full items-center justify-center">
- <div className="space-y-8">
- <div className="space-y-4 text-center">
- <FileSearchIcon className="mb-4 inline-block size-24 text-muted-foreground" />
- <div className="mb-2 font-bold text-3xl text-foreground">
- {t("errors_notFoundTitle")}
- </div>
- <p className="text-muted-foreground">
- {t("errors_notFoundDescription")}
- </p>
- </div>
- <div className="flex justify-center space-x-3">
- <Button variant="primary" asChild>
- <Link href="/">{t("errors_goToHome")}</Link>
- </Button>
- <Button asChild>
- <Link
- href="https://support.rallly.co"
- passHref={true}
- className="btn-default"
- >
- {t("common_support")}
- </Link>
- </Button>
- </div>
- </div>
- </div>
+ <ErrorPage
+ label={t("notFoundLabel", { defaultValue: "404" })}
+ title={t("notFoundTitle", { defaultValue: "Page not found" })}
+ description={t("notFoundDescription", {
+ defaultValue:
+ "Sorry, we couldn't find the page you're looking for. Here are some helpful links instead.",
+ })}
+ actions={
+ <Button variant="primary" asChild>
+ <Link href="/">
+ {t("errorBackToHome", { defaultValue: "Back to home" })}
+ </Link>
+ </Button>
+ }
+ >
+ <ErrorPageLinkItem
+ href="/"
+ icon={<HomeIcon className="size-4 text-muted-foreground" />}
+ title={t("errorLinkHome", { defaultValue: "Home" })}
+ description={t("errorLinkHomeDescription", {
+ defaultValue: "Go back to your dashboard.",
+ })}
+ />
+ <ErrorPageLinkItem
+ href="/new"
+ icon={<PlusIcon className="size-4 text-muted-foreground" />}
+ title={t("errorLinkCreatePoll", { defaultValue: "Create a Poll" })}
+ description={t("errorLinkCreatePollDescription", {
+ defaultValue: "Start scheduling a new meeting.",
+ })}
+ />
+ <ErrorPageLinkItem
+ href="https://support.rallly.co"
+ icon={<LifeBuoyIcon className="size-4 text-muted-foreground" />}
+ title={t("errorLinkSupport", { defaultValue: "Support" })}
+ description={t("errorLinkSupportDescription", {
+ defaultValue: "Browse our help articles and FAQs.",
+ })}
+ />
+ <ErrorPageLinkItem
+ href="https://github.com/lukevella/rallly"
+ icon={<GithubIcon className="size-4 text-muted-foreground" />}
+ title={t("errorLinkGithub", { defaultValue: "GitHub" })}
+ description={t("errorLinkGithubDescription", {
+ defaultValue: "Report an issue or check for updates.",
+ })}
+ />
+ </ErrorPage>
);
}
diff --git a/apps/web/src/components/error-page.tsx b/apps/web/src/components/error-page.tsx
index d14d40339..073d1aeb7 100644
--- a/apps/web/src/components/error-page.tsx
+++ b/apps/web/src/components/error-page.tsx
@@ -1,47 +1,92 @@
-import { Button } from "@rallly/ui/button";
-import { FrownIcon } from "lucide-react";
-import Link from "next/link";
-import type * as React from "react";
-
-import { useTranslation } from "@/i18n/client";
+"use client";
-export interface ComponentProps {
- icon?: React.ComponentType<{ className?: string }>;
- title: string;
- description: string;
-}
+import { ChevronRightIcon } from "lucide-react";
+import Image from "next/image";
+import Link from "next/link";
-const ErrorPage: React.FunctionComponent<ComponentProps> = ({
- icon: Icon = FrownIcon,
+export function ErrorPage({
+ label,
title,
description,
-}) => {
- const { t } = useTranslation();
+ children,
+ actions,
+}: {
+ label: React.ReactNode;
+ title: React.ReactNode;
+ description: React.ReactNode;
+ children: React.ReactNode;
+ actions: React.ReactNode;
+}) {
return (
- <div className="flex h-[calc(100vh-100px)] w-full items-center justify-center">
- <div className="space-y-8">
- <div className="space-y-4 text-center">
- <Icon className="mb-4 inline-block size-24 text-muted-foreground" />
- <div className="mb-2 font-bold text-3xl text-foreground">{title}</div>
- <p className="text-muted-foreground">{description}</p>
+ <div className="bg-background">
+ <main className="mx-auto w-full max-w-7xl px-6 pt-10 pb-16 sm:pb-24 lg:px-8">
+ <Image
+ src="/static/logo.svg"
+ alt="Rallly"
+ width={130}
+ height={30}
+ className="mx-auto dark:hidden"
+ />
+ <Image
+ src="/static/logo-dark.svg"
+ alt="Rallly"
+ width={130}
+ height={30}
+ className="mx-auto hidden dark:block"
+ />
+ <div className="mx-auto mt-20 max-w-2xl text-center sm:mt-24">
+ <p className="font-semibold text-base/8 text-primary">{label}</p>
+ <h1 className="mt-4 text-balance font-semibold text-5xl text-foreground tracking-tight sm:text-6xl">
+ {title}
+ </h1>
+ <p className="mt-6 text-pretty text-lg text-muted-foreground sm:text-xl/8">
+ {description}
+ </p>
</div>
- <div className="flex justify-center space-x-3">
- <Button variant="primary" asChild>
- <Link href="/">{t("errors_goToHome")}</Link>
- </Button>
- <Button asChild>
- <Link
- href="https://support.rallly.co"
- passHref={true}
- className="btn-default"
- >
- {t("common_support")}
- </Link>
- </Button>
+ <div className="mx-auto mt-16 flow-root max-w-lg sm:mt-20">
+ <ul className="-mt-6 divide-y divide-border border-border border-b">
+ {children}
+ </ul>
+ <div className="mt-10 flex items-center justify-center gap-x-4">
+ {actions}
+ </div>
</div>
- </div>
+ </main>
</div>
);
-};
+}
-export default ErrorPage;
+export function ErrorPageLinkItem({
+ href,
+ icon,
+ title,
+ description,
+}: {
+ href: string;
+ icon: React.ReactNode;
+ title: React.ReactNode;
+ description: React.ReactNode;
+}) {
+ return (
+ <li className="relative flex gap-x-6 py-6">
+ <div className="flex size-10 flex-none items-center justify-center rounded-lg border border-border bg-card">
+ {icon}
+ </div>
+ <div className="flex-auto">
+ <h3 className="font-semibold text-foreground text-sm">
+ <Link href={href}>
+ <span aria-hidden="true" className="absolute inset-0" />
+ {title}
+ </Link>
+ </h3>
+ <p className="mt-1 text-muted-foreground text-sm/6">{description}</p>
+ </div>
+ <div className="flex-none self-center">
+ <ChevronRightIcon
+ aria-hidden="true"
+ className="size-4 text-muted-foreground"
+ />
+ </div>
+ </li>
+ );
+}
diff --git a/apps/web/src/components/poll-context.tsx b/apps/web/src/components/poll-context.tsx
index 3cb9147d3..798f50745 100644
--- a/apps/web/src/components/poll-context.tsx
+++ b/apps/web/src/components/poll-context.tsx
@@ -12,7 +12,6 @@ import type {
import { getDuration } from "@/utils/date-time-utils";
import { useDayjs } from "@/utils/dayjs";
-import ErrorPage from "./error-page";
import { useParticipants } from "./participants-provider";
import { useRequiredContext } from "./use-required-context";
@@ -134,11 +133,15 @@ export const PollContextProvider: React.FunctionComponent<{
if (poll.deleted) {
return (
- <ErrorPage
- icon={TrashIcon}
- title={t("deletedPoll")}
- description={t("deletedPollInfo")}
- />
+ <div className="flex h-[calc(100vh-100px)] w-full items-center justify-center">
+ <div className="space-y-4 text-center">
+ <TrashIcon className="mb-4 inline-block size-24 text-muted-foreground" />
+ <div className="mb-2 font-bold text-3xl text-foreground">
+ {t("deletedPoll")}
+ </div>
+ <p className="text-muted-foreground">{t("deletedPollInfo")}</p>
+ </div>
+ </div>
);
}
return (
diff --git a/apps/web/tests/admin-setup.spec.ts b/apps/web/tests/admin-setup.spec.ts
index db99c280d..4296006b0 100644
--- a/apps/web/tests/admin-setup.spec.ts
+++ b/apps/web/tests/admin-setup.spec.ts
@@ -62,7 +62,7 @@ test.describe("Admin Setup Page Access", () => {
await loginWithEmail(page, { email: REGULAR_USER_EMAIL });
await page.goto("/control-panel/setup");
- await expect(page.getByText("404 not found")).toBeVisible();
+ await expect(page.getByText("Page not found")).toBeVisible();
});
test("should redirect an existing admin user to control-panel", async ({
@@ -90,7 +90,7 @@ test.describe("Admin Setup Page Access", () => {
await loginWithEmail(page, { email: OTHER_USER_EMAIL });
await page.goto("/control-panel/setup");
- await expect(page.getByText("404 not found")).toBeVisible();
+ await expect(page.getByText("Page not found")).toBeVisible();
});
test("initial admin can make themselves admin using the button", async ({
diff --git a/apps/web/tests/control-panel.spec.ts b/apps/web/tests/control-panel.spec.ts
index 7203f7080..d21edd15b 100644
--- a/apps/web/tests/control-panel.spec.ts
+++ b/apps/web/tests/control-panel.spec.ts
@@ -37,7 +37,7 @@ test.describe
await page.goto("/control-panel");
- await expect(page.getByText("404 not found")).toBeVisible();
+ await expect(page.getByText("Page not found")).toBeVisible();
});
test("should allow an admin user to access the control panel", async ({