Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
✨ Show instance footer links on the 404, error and unavailable poll pages (#3276)
Luke Vella073b103fa36c
diff --git a/apps/web/src/app/[locale]/invite/[urlId]/page.tsx b/apps/web/src/app/[locale]/invite/[urlId]/page.tsxindex d58d1eb80..e081653e4 100644--- a/apps/web/src/app/[locale]/invite/[urlId]/page.tsx+++ b/apps/web/src/app/[locale]/invite/[urlId]/page.tsx@@ -68,7 +68,8 @@ export default async function Page(props: {]);if (unavailable) {- return <PollUnavailable reason={unavailable} />;+ const footerLinks = await loadFooterLinks();+ return <PollUnavailable reason={unavailable} footerLinks={footerLinks} />;}// The SSR helper reads the session; an unavailable poll never needs it.diff --git a/apps/web/src/app/[locale]/not-found.tsx b/apps/web/src/app/[locale]/not-found.tsxindex d6a01b2d5..1e7c715e4 100644--- a/apps/web/src/app/[locale]/not-found.tsx+++ b/apps/web/src/app/[locale]/not-found.tsx@@ -1,14 +1,19 @@import { buttonVariants } from "@rallly/ui";import { GithubIcon, HomeIcon, LifeBuoyIcon, PlusIcon } from "lucide-react";import { ErrorPage, ErrorPageLinkItem } from "@/components/error-page";+import { InstanceFooterLinks } from "@/components/instance-footer-links";import { Link } from "@/components/link";import { DefaultLogo } from "@/features/branding/components/default-logo";+import { loadFooterLinks } from "@/features/instance-settings/loaders";import { getTranslation } from "@/i18n/server";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");+ const [{ t }, footerLinks] = await Promise.all([+ getTranslation("en"),+ loadFooterLinks(),+ ]);return (<ErrorPage@@ -27,6 +32,11 @@ export default async function NotFoundPage() {{t("errorBackToHome", { defaultValue: "Back to home" })}</Link>}+ footer={+ footerLinks.length > 0 ? (+ <InstanceFooterLinks links={footerLinks} />+ ) : null+ }><ErrorPageLinkItemhref="/"diff --git a/apps/web/src/components/error-page.tsx b/apps/web/src/components/error-page.tsxindex 44a0a72fa..f74b8c9d9 100644--- a/apps/web/src/components/error-page.tsx+++ b/apps/web/src/components/error-page.tsx@@ -10,6 +10,7 @@ export function ErrorPage({description,children,actions,+ footer,}: {logo: React.ReactNode;label: React.ReactNode;@@ -17,13 +18,14 @@ export function ErrorPage({description: React.ReactNode;children: React.ReactNode;actions: React.ReactNode;+ footer?: React.ReactNode;}) {return (- <div className="page-bg-gray-100">+ <div className="page-bg-gray-100 flex min-h-dvh flex-col"><mainid="main-content"tabIndex={-1}- className="mx-auto w-full max-w-7xl px-6 pt-10 pb-16 sm:pb-24 lg:px-8"+ className="mx-auto w-full max-w-7xl flex-1 px-6 pt-10 pb-16 sm:pb-24 lg:px-8"><header className="flex justify-center">{logo}</header><div className="mx-auto mt-16 max-w-2xl text-center">@@ -42,6 +44,11 @@ export function ErrorPage({</div></div></main>+ {footer ? (+ <footer className="mx-auto w-full max-w-7xl px-6 pb-10 lg:px-8">+ {footer}+ </footer>+ ) : null}</div>);}diff --git a/apps/web/src/features/poll/invite/components/poll-unavailable.tsx b/apps/web/src/features/poll/invite/components/poll-unavailable.tsxindex cceac243b..bb7757968 100644--- a/apps/web/src/features/poll/invite/components/poll-unavailable.tsx+++ b/apps/web/src/features/poll/invite/components/poll-unavailable.tsx@@ -9,79 +9,61 @@ import {EmptyStateIcon,EmptyStateTitle,} from "@/components/empty-state";+import { InstanceFooterLinks } from "@/components/instance-footer-links";import { Link } from "@/components/link";import { DefaultLogo } from "@/features/branding/components/default-logo";import { getTranslation } from "@/i18n/server";export type PollUnavailableReason = "deleted" | "removed";+function PollUnavailableShell({+ footerLinks,+ children,+}: {+ footerLinks: { label: string; href: string }[];+ children: React.ReactNode;+}) {+ return (+ <div className="flex min-h-dvh flex-col">+ <main id="main-content" tabIndex={-1} className="flex-1 p-4 pt-10">+ <DefaultLogo className="mx-auto" />+ <EmptyState className="py-12">{children}</EmptyState>+ </main>+ {footerLinks.length > 0 ? (+ <footer className="flex justify-center p-4 pb-10">+ <InstanceFooterLinks links={footerLinks} />+ </footer>+ ) : null}+ </div>+ );+}+// Shown in place of the invite page when the poll exists but must not be// served. "removed" means the creator was banned, which is usually a scam:// the viewer is the intended victim, so the copy warns them. It never names// the poll, its creator, or a reason more specific than the terms of use.export async function PollUnavailable({reason,+ footerLinks,}: {reason: PollUnavailableReason;+ footerLinks: { label: string; href: string }[];}) {const { t, i18n } = await getTranslation();if (reason === "deleted") {return (- <main id="main-content" tabIndex={-1} className="p-4 pt-10">- <DefaultLogo className="mx-auto" />- <EmptyState className="py-12">- <EmptyStateIcon>- <TrashIcon />- </EmptyStateIcon>- <EmptyStateTitle as="h1">- <Trans- t={t}- i18n={i18n}- ns="app"- i18nKey="pollDeletedTitle"- defaults="This poll has been deleted"- />- </EmptyStateTitle>- <EmptyStateDescription>- <Trans- t={t}- i18n={i18n}- ns="app"- i18nKey="pollDeletedDescription"- defaults="It may have been deleted by its creator or removed after a period of inactivity."- />- </EmptyStateDescription>- <EmptyStateFooter>- <Link href="/" className={buttonVariants()}>- <Trans- t={t}- i18n={i18n}- ns="app"- i18nKey="errorBackToHome"- defaults="Back to home"- />- </Link>- </EmptyStateFooter>- </EmptyState>- </main>- );- }-- return (- <main id="main-content" tabIndex={-1} className="p-4 pt-10">- <DefaultLogo className="mx-auto" />- <EmptyState className="py-12">+ <PollUnavailableShell footerLinks={footerLinks}><EmptyStateIcon>- <ShieldAlertIcon />+ <TrashIcon /></EmptyStateIcon><EmptyStateTitle as="h1"><Transt={t}i18n={i18n}ns="app"- i18nKey="pollRemovedTitle"- defaults="This poll has been removed"+ i18nKey="pollDeletedTitle"+ defaults="This poll has been deleted"/></EmptyStateTitle><EmptyStateDescription>@@ -89,32 +71,69 @@ export async function PollUnavailable({t={t}i18n={i18n}ns="app"- i18nKey="pollRemovedDescription"- defaults="It violated our terms of use and is no longer available."+ i18nKey="pollDeletedDescription"+ defaults="It may have been deleted by its creator or removed after a period of inactivity."/></EmptyStateDescription>- <Alert variant="warning" className="mt-6 max-w-md">- <ShieldAlertIcon />- <AlertTitle>+ <EmptyStateFooter>+ <Link href="/" className={buttonVariants()}><Transt={t}i18n={i18n}ns="app"- i18nKey="pollRemovedWarningTitle"- defaults="Weren't expecting this link?"+ i18nKey="errorBackToHome"+ defaults="Back to home"/>- </AlertTitle>- <AlertDescription>- <Trans- t={t}- i18n={i18n}- ns="app"- i18nKey="pollRemovedWarningDescription"- defaults="Treat the message that sent you here as suspicious. Do not call phone numbers, follow links, or send money or personal details in response to it."- />- </AlertDescription>- </Alert>- </EmptyState>- </main>+ </Link>+ </EmptyStateFooter>+ </PollUnavailableShell>+ );+ }++ return (+ <PollUnavailableShell footerLinks={footerLinks}>+ <EmptyStateIcon>+ <ShieldAlertIcon />+ </EmptyStateIcon>+ <EmptyStateTitle as="h1">+ <Trans+ t={t}+ i18n={i18n}+ ns="app"+ i18nKey="pollRemovedTitle"+ defaults="This poll has been removed"+ />+ </EmptyStateTitle>+ <EmptyStateDescription>+ <Trans+ t={t}+ i18n={i18n}+ ns="app"+ i18nKey="pollRemovedDescription"+ defaults="It violated our terms of use and is no longer available."+ />+ </EmptyStateDescription>+ <Alert variant="warning" className="mt-6 max-w-md">+ <ShieldAlertIcon />+ <AlertTitle>+ <Trans+ t={t}+ i18n={i18n}+ ns="app"+ i18nKey="pollRemovedWarningTitle"+ defaults="Weren't expecting this link?"+ />+ </AlertTitle>+ <AlertDescription>+ <Trans+ t={t}+ i18n={i18n}+ ns="app"+ i18nKey="pollRemovedWarningDescription"+ defaults="Treat the message that sent you here as suspicious. Do not call phone numbers, follow links, or send money or personal details in response to it."+ />+ </AlertDescription>+ </Alert>+ </PollUnavailableShell>);}