The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Add upgrade banner
Tim Wilson9d425d9ae3f5
diff --git a/apps/web/app/app.dub.co/(dashboard)/layout.tsx b/apps/web/app/app.dub.co/(dashboard)/layout.tsxindex cfd9f3d650..1440ed3333 100644--- a/apps/web/app/app.dub.co/(dashboard)/layout.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/layout.tsx@@ -4,6 +4,7 @@ import { HelpButtonRSC } from "@/ui/layout/sidebar/help-button-rsc";import { NewsRSC } from "@/ui/layout/sidebar/news-rsc";import { ReferButton } from "@/ui/layout/sidebar/refer-button";import Toolbar from "@/ui/layout/toolbar/toolbar";+import { UpgradeBanner } from "@/ui/layout/upgrade-banner";import { constructMetadata } from "@dub/utils";import { ReactNode } from "react";@@ -14,6 +15,7 @@ export default async function Layout({ children }: { children: ReactNode }) {return (<><div className="min-h-screen w-full bg-white">+ <UpgradeBanner /><MainNavsidebar={AppSidebarNav}toolContent={diff --git a/apps/web/ui/layout/upgrade-banner.tsx b/apps/web/ui/layout/upgrade-banner.tsxnew file mode 100644index 0000000000..6ee4989e63--- /dev/null+++ b/apps/web/ui/layout/upgrade-banner.tsx@@ -0,0 +1,57 @@+"use client";++import useWorkspace from "@/lib/swr/use-workspace";+import { Crown } from "@dub/ui";+import { cn, getNextPlan } from "@dub/utils";+import { motion } from "framer-motion";+import Link from "next/link";+import { useMemo } from "react";++export function UpgradeBanner() {+ const { slug, plan, usage, usageLimit, linksUsage, linksLimit } =+ useWorkspace();++ const needsUpgrade = useMemo(+ () =>+ [+ [usage, usageLimit],+ [linksUsage, linksLimit],+ ].some(+ ([usage, limit]) =>+ usage !== undefined && limit !== undefined && usage > limit,+ ),+ [usage, usageLimit, linksUsage, linksLimit],+ );++ if (!needsUpgrade || !plan) return null;++ return (+ <motion.div+ initial={{ height: 0 }}+ animate={{ height: "48px" }}+ className="text-content-inverted bg-bg-inverted flex h-12 items-center justify-center overflow-hidden px-6"+ >+ <Crown className="mr-2 size-4 shrink-0" />+ <p className="text-sm">+ You’ve hit the{" "}+ <Link href={`/${slug}/settings/billing`} className="underline">+ monthly usage limit+ </Link>+ <span className="xs:inline hidden"> on your current plan</span>+ <span className="hidden md:inline">. Upgrade to keep creating.</span>+ </p>+ <Link+ href={`/${slug}/upgrade`}+ className={cn(+ "bg-bg-default text-content-emphasis border-border-subtle ml-4 flex h-7 items-center justify-center rounded-lg border px-2.5 text-sm font-medium",+ "hover:bg-bg-subtle transition-colors duration-150",+ )}+ >+ Upgrade+ <span className="hidden sm:inline">+ to {getNextPlan(plan).name}+ </span>+ </Link>+ </motion.div>+ );+}