Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
✨ Show a header to poll managers on the invite page (#3514)
Luke Vellabf10d2abc061
diff --git a/apps/web/public/locales/en/app.json b/apps/web/public/locales/en/app.jsonindex deb809efb..92dace239 100644--- a/apps/web/public/locales/en/app.json+++ b/apps/web/public/locales/en/app.json@@ -364,7 +364,6 @@"errorTitle": "Something went wrong","errorTryAgain": "Try again","event": "Event",- "eventHostDescription": "You are the creator of this poll","eventPageAbout": "About","eventPageGoingCount": "{count, plural, one {# going} other {# going}}","eventRegisterAlreadyResponded": "This email has already been used to respond",@@ -489,6 +488,7 @@"inviteMemberFormSubmit": "Send invite","inviteMembersUpsellDescription": "Invite members to manage polls and events together in this space.","inviteNotEnoughSeats": "There are not enough seats available to send this invite",+ "invitePageManagerNotice": "You're viewing this poll as a participant","invitePending": "An invitation has already been sent to this email address","inviteSent": "Invitation sent","inviteStatusOpened": "Opened",@@ -576,6 +576,7 @@"makeMember": "Make member","manage": "Manage","manageBilling": "Manage billing",+ "managePoll": "Manage poll","manageSeats": "Manage seats","manageSeatsDescription": "Adjust the number of seats for your space.","manageSeatsInputLabel": "Number of seats",diff --git a/apps/web/src/app/[locale]/invite/[urlId]/invite-page.tsx b/apps/web/src/app/[locale]/invite/[urlId]/invite-page.tsxindex 85ddc6a70..7db1c04e6 100644--- a/apps/web/src/app/[locale]/invite/[urlId]/invite-page.tsx+++ b/apps/web/src/app/[locale]/invite/[urlId]/invite-page.tsx@@ -1,11 +1,15 @@"use client";+import { buttonVariants } from "@rallly/ui";+import { ArrowUpRightIcon, EyeIcon } from "lucide-react";+import { Link } from "@/components/link";import { Spinner } from "@/components/spinner";import { EventCard } from "@/features/poll/components/event-card";import { PollFooter } from "@/features/poll/components/poll-footer";+import { PollPageShell } from "@/features/poll/components/poll-page-shell";import { ResponsiveResults } from "@/features/poll/components/responsive-results";import { VotingForm } from "@/features/poll/components/voting-form";-import { CreatorBanner } from "@/features/poll/invite/components/creator-banner";import { FloatingComments } from "@/features/poll/invite/components/floating-comments";+import { Trans } from "@/i18n/client";import { useHydrated } from "@/lib/datetime/use-hydrated";/**@@ -17,13 +21,21 @@ import { useHydrated } from "@/lib/datetime/use-hydrated";* while its data loads, so there is one loader from first byte to* interactive. The page's server props are already in the tree by then, so* nothing else is fetched.+ *+ * A viewer who can manage the poll gets the admin page's frame, with a+ * way through to it in place of the admin controls, so switching between+ * the two pages does not shift the layout.*/export function InvitePage({+ pollId,description,footerLinks,+ canManage,}: {+ pollId: string;description: React.ReactNode;footerLinks: { label: string; href: string }[];+ canManage: boolean;}) {const hydrated = useHydrated();@@ -31,6 +43,48 @@ export function InvitePage({return <InvitePageLoading />;}+ const content = (+ <>+ <EventCard description={description} />+ <VotingForm>+ <ResponsiveResults />+ <FloatingComments />+ </VotingForm>+ <PollFooter footerLinks={footerLinks} />+ <div className="h-24 lg:hidden" />+ </>+ );++ if (canManage) {+ return (+ <PollPageShell+ header={+ <p className="flex min-w-0 items-center gap-x-2 text-muted-foreground text-sm">+ <EyeIcon className="size-4 shrink-0" />+ <span className="truncate">+ <Trans+ i18nKey="invitePageManagerNotice"+ defaults="You're viewing this poll as a participant"+ />+ </span>+ </p>+ }+ actions={+ <Link+ className={buttonVariants()}+ href={`/poll/${pollId}`}+ prefetch={false}+ >+ <Trans i18nKey="managePoll" defaults="Manage poll" />+ <ArrowUpRightIcon data-icon="inline-end" />+ </Link>+ }+ >+ {content}+ </PollPageShell>+ );+ }+return (<div className="page-bg-gray-100 relative h-dvh overflow-auto p-3 lg:p-6 dark:bg-gray-900"><main@@ -38,14 +92,7 @@ export function InvitePage({tabIndex={-1}className="mx-auto w-full max-w-4xl space-y-3">- <CreatorBanner />- <EventCard description={description} />- <VotingForm>- <ResponsiveResults />- <FloatingComments />- </VotingForm>- <PollFooter footerLinks={footerLinks} />- <div className="h-24 lg:hidden" />+ {content}</main></div>);diff --git a/apps/web/src/app/[locale]/invite/[urlId]/page.tsx b/apps/web/src/app/[locale]/invite/[urlId]/page.tsxindex 48f685dd6..847b8b9d3 100644--- a/apps/web/src/app/[locale]/invite/[urlId]/page.tsx+++ b/apps/web/src/app/[locale]/invite/[urlId]/page.tsx@@ -12,6 +12,7 @@ import { VisibilityProvider } from "@/features/poll/components/visibility";import { InviteOpenRecorder } from "@/features/poll/invite/components/invite-open-recorder";import { PollUnavailable } from "@/features/poll/invite/components/poll-unavailable";import { loadInvitePoll, loadPollAvailability } from "@/features/poll/loaders";+import { loadCanManagePoll } from "@/features/poll/vote/loaders";import { UserProvider } from "@/features/user/client";import { getLocale } from "@/i18n/server/get-locale";import { DeviceDateTimeProvider } from "@/lib/datetime/device";@@ -58,11 +59,13 @@ async function InvitePageContent({ params, searchParams }: PageProps) {locale,deviceDateTimeConfig,footerLinks,+ canManage,] = await Promise.all([loadInvitePoll({ pollId: urlId, token }),getLocale(),getDeviceDateTimeConfig(),loadFooterLinks(),+ loadCanManagePoll(urlId),]);return (@@ -86,6 +89,8 @@ async function InvitePageContent({ params, searchParams }: PageProps) {<VisibilityProvider><PollBrandingFromContext /><InvitePage+ pollId={poll.id}+ canManage={canManage}// Rendered here so the markdown parser stays on the serverdescription={<EventMetaDescriptiondiff --git a/apps/web/src/features/poll/components/poll-layout.tsx b/apps/web/src/features/poll/components/poll-layout.tsxindex 3b257e1a2..42b85be69 100644--- a/apps/web/src/features/poll/components/poll-layout.tsx+++ b/apps/web/src/features/poll/components/poll-layout.tsx@@ -15,16 +15,17 @@ import { usePoll } from "@/features/poll/client";import ManagePoll from "@/features/poll/components/manage-poll";import { NotificationToggle } from "@/features/poll/components/notification-toggle";import { LegacyPollContextProvider } from "@/features/poll/components/poll-context-provider";+import { PollPageShell } from "@/features/poll/components/poll-page-shell";import { PollPrimaryActions } from "@/features/poll/components/poll-primary-actions";import { Trans } from "@/i18n/client";const AdminControls = () => {return (- <div className="flex items-center gap-x-2">+ <><NotificationToggle /><ManagePoll /><PollPrimaryActions />- </div>+ </>);};@@ -33,48 +34,41 @@ const Layout = ({ children }: React.PropsWithChildren) => {const pollLink = `/poll/${poll.id}`;const pathname = usePathname();return (- <div className="page-bg-gray-100 relative h-dvh overflow-auto dark:bg-gray-900">- <div className="sticky top-0 z-40 border-b bg-gray-100/90 p-3 backdrop-blur-lg sm:flex-row dark:bg-gray-900/90">- <div className="flex justify-between">- <div className="flex min-w-0 items-center gap-x-2.5">- <Breadcrumb className="min-w-0">- <BreadcrumbList className="flex-nowrap">- <BreadcrumbItem className="shrink-0">- <BreadcrumbLink- className="flex items-center gap-x-2"- render={<Link href="/polls" />}- >- <BarChart2Icon className="size-4" />- <Trans i18nKey="polls" defaults="Polls" />- </BreadcrumbLink>- </BreadcrumbItem>- <BreadcrumbSeparator className="shrink-0" />- <BreadcrumbItem className="min-w-0">- {pathname === pollLink ? (- <BreadcrumbPage className="truncate">- {poll.title}- </BreadcrumbPage>- ) : (- <BreadcrumbLink- className="truncate"- render={<Link href={pollLink} />}- >- {poll.title}- </BreadcrumbLink>- )}- </BreadcrumbItem>- </BreadcrumbList>- </Breadcrumb>- </div>- <div>- <AdminControls />- </div>- </div>- </div>- <main id="main-content" tabIndex={-1} className="p-3">- <div className="mx-auto max-w-4xl space-y-3">{children}</div>- </main>- </div>+ <PollPageShell+ header={+ <Breadcrumb className="min-w-0">+ <BreadcrumbList className="flex-nowrap">+ <BreadcrumbItem className="shrink-0">+ <BreadcrumbLink+ className="flex items-center gap-x-2"+ render={<Link href="/polls" />}+ >+ <BarChart2Icon className="size-4" />+ <Trans i18nKey="polls" defaults="Polls" />+ </BreadcrumbLink>+ </BreadcrumbItem>+ <BreadcrumbSeparator className="shrink-0" />+ <BreadcrumbItem className="min-w-0">+ {pathname === pollLink ? (+ <BreadcrumbPage className="truncate">+ {poll.title}+ </BreadcrumbPage>+ ) : (+ <BreadcrumbLink+ className="truncate"+ render={<Link href={pollLink} />}+ >+ {poll.title}+ </BreadcrumbLink>+ )}+ </BreadcrumbItem>+ </BreadcrumbList>+ </Breadcrumb>+ }+ actions={<AdminControls />}+ >+ {children}+ </PollPageShell>);};diff --git a/apps/web/src/features/poll/components/poll-page-shell.tsx b/apps/web/src/features/poll/components/poll-page-shell.tsxnew file mode 100644index 000000000..0a8550a90--- /dev/null+++ b/apps/web/src/features/poll/components/poll-page-shell.tsx@@ -0,0 +1,43 @@+"use client";+import { cn } from "@rallly/ui";+import React from "react";++/**+ * The page frame shared by the admin page and the invite page a manager+ * sees: a sticky header bar above a scrolling column. Both pages render+ * through it so moving between them does not shift the layout. The+ * header's border only shows once the content has scrolled beneath it.+ */+export function PollPageShell({+ header,+ actions,+ children,+}: {+ header: React.ReactNode;+ actions: React.ReactNode;+ children: React.ReactNode;+}) {+ const [scrolled, setScrolled] = React.useState(false);++ return (+ <div+ className="page-bg-gray-100 relative h-dvh overflow-auto dark:bg-gray-900"+ onScroll={(e) => setScrolled(e.currentTarget.scrollTop > 0)}+ >+ <div+ className={cn(+ "sticky top-0 z-40 border-b bg-gray-100/90 p-3 backdrop-blur-lg dark:bg-gray-900/90",+ !scrolled && "border-transparent",+ )}+ >+ <div className="flex justify-between gap-x-2">+ <div className="flex min-w-0 items-center gap-x-2.5">{header}</div>+ <div className="flex shrink-0 items-center gap-x-2">{actions}</div>+ </div>+ </div>+ <main id="main-content" tabIndex={-1} className="p-3">+ <div className="mx-auto max-w-4xl space-y-3">{children}</div>+ </main>+ </div>+ );+}diff --git a/apps/web/src/features/poll/invite/components/creator-banner.tsx b/apps/web/src/features/poll/invite/components/creator-banner.tsxdeleted file mode 100644index d16f6e6d4..000000000--- a/apps/web/src/features/poll/invite/components/creator-banner.tsx+++ /dev/null@@ -1,42 +0,0 @@-"use client";-import { buttonVariants } from "@rallly/ui";-import { Alert, AlertAction, AlertDescription } from "@rallly/ui/alert";-import { ArrowUpRightIcon, CrownIcon } from "lucide-react";-import { Link } from "@/components/link";-import { usePoll } from "@/features/poll/client";-import { useUser } from "@/features/user/client";-import { Trans } from "@/i18n/client";--/** Points the poll's creator from the participant view to the admin page. */-export function CreatorBanner() {- const poll = usePoll();- const { user } = useUser();-- if (!user || user.id !== poll.userId) {- return null;- }-- return (- <Alert variant="primary">- <CrownIcon />- <AlertDescription>- <p>- <Trans- i18nKey="eventHostDescription"- defaults="You are the creator of this poll"- />- </p>- </AlertDescription>- <AlertAction>- <Link- className={buttonVariants({ variant: "primary", size: "sm" })}- href={`/poll/${poll.id}`}- prefetch={false}- >- <Trans i18nKey="manage" defaults="Manage" />- <ArrowUpRightIcon className="size-4" />- </Link>- </AlertAction>- </Alert>- );-}