The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
program/link-settings + PageContent improvements
Steven Teya8c064d0bdec
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/auth.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/auth.tsxindex c3f5b50851..583b3678f9 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/auth.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/auth.tsx@@ -3,13 +3,12 @@import { getPlanCapabilities } from "@/lib/plan-capabilities";import useWorkspace from "@/lib/swr/use-workspace";import LayoutLoader from "@/ui/layout/layout-loader";-import { PageContentOld } from "@/ui/layout/page-content";-import { redirect, useRouter } from "next/navigation";+import { PageContent } from "@/ui/layout/page-content";+import { redirect } from "next/navigation";import { ReactNode, useEffect, useState } from "react";import { PartnersUpgradeCTA } from "./partners-ugrade-cta";export default function ProgramAuth({ children }: { children: ReactNode }) {- const router = useRouter();const {slug,plan,@@ -36,9 +35,9 @@ export default function ProgramAuth({ children }: { children: ReactNode }) {if (!getPlanCapabilities(plan).canManageProgram) {return (- <PageContentOld>+ <PageContent><PartnersUpgradeCTA />- </PageContentOld>+ </PageContent>);}diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/communication/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/communication/page-client.tsxindex 37c0be5e3b..9c1c7e4027 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/communication/page-client.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/communication/page-client.tsx@@ -10,7 +10,7 @@ import { useAction } from "next-safe-action/hooks";import { useForm } from "react-hook-form";import { toast } from "sonner";import { mutate } from "swr";-import { SettingsRow } from "../settings/settings-row";+import { SettingsRow } from "../program-settings-row";type FormData = Pick<ProgramProps, "supportEmail" | "helpUrl" | "termsUrl">;diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/links/links-settings.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/link-settings/form.tsxsimilarity index 99%rename from apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/links/links-settings.tsxrename to apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/link-settings/form.tsxindex 0a6481fb35..a972e42a65 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/links/links-settings.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/link-settings/form.tsx@@ -14,7 +14,7 @@ import { useAction } from "next-safe-action/hooks";import { useForm } from "react-hook-form";import { toast } from "sonner";import { mutate } from "swr";-import { SettingsRow } from "../settings/settings-row";+import { SettingsRow } from "../program-settings-row";type FormData = Pick<ProgramProps,diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/links/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/link-settings/page.tsxsimilarity index 87%rename from apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/links/page.tsxrename to apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/link-settings/page.tsxindex 6d7cc297e4..ac18e651f3 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/links/page.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/link-settings/page.tsx@@ -1,6 +1,6 @@import { PageContent } from "@/ui/layout/page-content";import { PageWidthWrapper } from "@/ui/layout/page-width-wrapper";-import { LinksSettings } from "./links-settings";+import { LinksSettings } from "./form";export default async function ProgramSettingsLinksPage() {return (diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/settings/settings-row.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/program-settings-row.tsxsimilarity index 100%rename from apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/settings/settings-row.tsxrename to apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/program-settings-row.tsxdiff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/rewards/settings.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/rewards/settings.tsxindex 1de8a3483b..dc0f8f1a7d 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/rewards/settings.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/rewards/settings.tsx@@ -13,7 +13,7 @@ import { useAction } from "next-safe-action/hooks";import { useForm } from "react-hook-form";import { toast } from "sonner";import { mutate } from "swr";-import { SettingsRow } from "../settings/settings-row";+import { SettingsRow } from "../program-settings-row";type FormData = Pick<ProgramProps, "holdingPeriodDays" | "minPayoutAmount">;diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/settings/layout.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/settings/layout.tsxdeleted file mode 100644index e03c7bf822..0000000000--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/settings/layout.tsx+++ /dev/null@@ -1,18 +0,0 @@-import { PageContentOld } from "@/ui/layout/page-content";-import { MaxWidthWrapper } from "@dub/ui";-import { PropsWithChildren } from "react";-import { ProgramSettingsHeader } from "./program-settings-header";--export default function ProgramSettingsLayout({- children,- params,-}: PropsWithChildren<{ params: { slug: string; programId: string } }>) {- return (- <PageContentOld title="Program Configuration">- <MaxWidthWrapper>- <ProgramSettingsHeader />- <div className="mb-10 mt-8 grid grid-cols-1 gap-8">{children}</div>- </MaxWidthWrapper>- </PageContentOld>- );-}diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/settings/program-settings-header.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/settings/program-settings-header.tsxdeleted file mode 100644index be9ac667df..0000000000--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/settings/program-settings-header.tsx+++ /dev/null@@ -1,43 +0,0 @@-"use client";--import { TabSelect } from "@dub/ui";-import { useParams, useSelectedLayoutSegment } from "next/navigation";--export function ProgramSettingsHeader() {- const { slug } = useParams();- const selectedLayoutSegment = useSelectedLayoutSegment();- const page = selectedLayoutSegment === null ? "" : selectedLayoutSegment;-- return (- <div className="border-b border-gray-200">- <div className="scrollbar-hide overflow-x-auto">- <TabSelect- variant="accent"- options={[- {- id: "rewards",- label: "Rewards",- href: `/${slug}/program/settings/rewards`,- },- {- id: "discounts",- label: "Discounts",- href: `/${slug}/program/settings/discounts`,- },- {- id: "links",- label: "Links",- href: `/${slug}/program/settings/links`,- },- {- id: "communication",- label: "Communication",- href: `/${slug}/program/settings/communication`,- },- ]}- selected={page}- />- </div>- </div>- );-}diff --git a/apps/web/lib/middleware/utils/app-redirect.ts b/apps/web/lib/middleware/utils/app-redirect.tsindex ff6ab5aaf4..623da57885 100644--- a/apps/web/lib/middleware/utils/app-redirect.ts+++ b/apps/web/lib/middleware/utils/app-redirect.ts@@ -1,5 +1,5 @@import { RESERVED_SLUGS } from "@dub/utils";-import { getDubProductFromCookie } from "./get-dub-product-from-cookie";+import { cookies } from "next/headers";const APP_REDIRECTS = {"/account": "/account/settings",@@ -17,8 +17,14 @@ export const appRedirect = (path: string) => {const rootRegex = /^\/([^\/]+)$/;if (rootRegex.test(path) && !RESERVED_SLUGS.includes(path.split("/")[1])) {// Determine product from cookie (default to links)- const workspace = path.split("/")[1];- const product = getDubProductFromCookie(workspace);+ let product = "links";++ const productCookie = cookies().get(+ `dub_product:${path.split("/")[1]}`,+ )?.value;++ if (productCookie && ["links", "program"].includes(productCookie))+ product = productCookie;return path.replace(rootRegex, `/$1/${product}`);}@@ -47,10 +53,15 @@ export const appRedirect = (path: string) => {`/${slug}/program${subPath ? `/${subPath}` : ""}`,);- // Redirect "/[slug]/program/settings" to "/[slug]/program/rewards" (original first tab of settings)- const programSettingsRegex = /\/program\/settings$/;- if (programSettingsRegex.test(path))- return path.replace(programSettingsRegex, "/program/rewards");+ // Redirect "/[slug]/program/settings" to "/[slug]/program"+ const programSettingsRootRegex = /\/program\/settings$/;+ if (programSettingsRootRegex.test(path))+ return path.replace(programSettingsRootRegex, "/program");++ // Redirect "/[slug]/program/settings/links" to "/[slug]/program/link-settings"+ const programSettingsLinksRegex = /\/program\/settings\/links$/;+ if (programSettingsLinksRegex.test(path))+ return path.replace(programSettingsLinksRegex, "/program/link-settings");// Redirect "/[slug]/program/settings/:path" to "/[slug]/program/:path"const programSettingsPathRegex = /^\/([^\/]+)\/program\/settings\/(.*)$/;diff --git a/apps/web/ui/layout/page-content/index.tsx b/apps/web/ui/layout/page-content/index.tsxindex e855699958..b324382042 100644--- a/apps/web/ui/layout/page-content/index.tsx+++ b/apps/web/ui/layout/page-content/index.tsx@@ -24,7 +24,18 @@ export function PageContent({className?: string;contentWrapperClassName?: string;}>) {- const hasTitle = title !== undefined;+ if (!title) {+ return (+ <div+ className={cn(+ "rounded-t-[inherit] bg-neutral-100 md:bg-white",+ className,+ )}+ >+ {children}+ </div>+ );+ }// Generate titleInfo from object if providedconst finalTitleInfo =@@ -57,22 +68,20 @@ export function PageContent({<div className="flex h-12 items-center justify-between gap-4 sm:h-16"><div className="flex min-w-0 items-center gap-4"><NavButton />- {hasTitle && (- <div className="flex items-center gap-2">- {titleBackHref && (- <Link- href={titleBackHref}- className="rounded-lg p-1.5 text-neutral-500 transition-colors hover:bg-neutral-100 hover:text-neutral-900"- >- <ChevronLeft className="size-5" />- </Link>- )}- <h1 className="text-content-emphasis text-lg font-semibold leading-7">- {title}- </h1>- {finalTitleInfo}- </div>- )}+ <div className="flex items-center gap-2">+ {titleBackHref && (+ <Link+ href={titleBackHref}+ className="rounded-lg p-1.5 text-neutral-500 transition-colors hover:bg-neutral-100 hover:text-neutral-900"+ >+ <ChevronLeft className="size-5" />+ </Link>+ )}+ <h1 className="text-content-emphasis text-lg font-semibold leading-7">+ {title}+ </h1>+ {finalTitleInfo}+ </div></div>{controls && (<div className="flex items-center gap-2">{controls}</div>diff --git a/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx b/apps/web/ui/layout/sidebar/app-sidebar-nav.tsxindex fe1626045a..72b37c3fca 100644--- a/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx+++ b/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx@@ -224,7 +224,7 @@ const NAV_AREAS: SidebarNavAreas<SidebarNavData> = {{name: "Link Settings",icon: Sliders,- href: `/${slug}/program/links`,+ href: `/${slug}/program/link-settings`,},{name: "Communication",