Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

showPartnersUpgradeModal, improve billing upgrade page

Steven Tey0185f255ccdc
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/confirm-create-bounty-modal.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/confirm-create-bounty-modal.tsx
index 4c57160720..771d174640 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/confirm-create-bounty-modal.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/confirm-create-bounty-modal.tsx
@@ -115,7 +115,7 @@ function ConfirmCreateBountyModal({
<TooltipContent
title="New bounty notifications are only available on Advanced plans and above."
cta="Upgrade to Advanced"
- href={`/${workspaceSlug}/upgrade?plan=advanced`}
+ href={`/${workspaceSlug}/upgrade?showPartnersUpgradeModal=true`}
target="_blank"
/>
),
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/campaigns/campaigns-upsell.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/campaigns/campaigns-upsell.tsx
index df047decdd..32b3e4bf95 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/campaigns/campaigns-upsell.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/campaigns/campaigns-upsell.tsx
@@ -9,9 +9,7 @@ import { CampaignsPageContent } from "./campaigns-page-content";
export function CampaignsUpsell() {
const { partnersUpgradeModal, setShowPartnersUpgradeModal } =
- usePartnersUpgradeModal({
- plan: "Advanced",
- });
+ usePartnersUpgradeModal();
return (
<CampaignsPageContent>
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/fraud/fraud-upsell.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/fraud/fraud-upsell.tsx
index 0839413f0e..87785e35ab 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/fraud/fraud-upsell.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/fraud/fraud-upsell.tsx
@@ -8,9 +8,7 @@ import { ExampleFraudEvents } from "./example-fraud-events";
export function FraudUpsell() {
const { partnersUpgradeModal, setShowPartnersUpgradeModal } =
- usePartnersUpgradeModal({
- plan: "Advanced",
- });
+ usePartnersUpgradeModal();
return (
<>
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/messages/messages-upsell.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/messages/messages-upsell.tsx
index 389ad1f804..8e9ae537e5 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/messages/messages-upsell.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/messages/messages-upsell.tsx
@@ -7,9 +7,7 @@ import { cn } from "@dub/utils";
export function MessagesUpsell() {
const { partnersUpgradeModal, setShowPartnersUpgradeModal } =
- usePartnersUpgradeModal({
- plan: "Advanced",
- });
+ usePartnersUpgradeModal();
return (
<PageContent
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/resources/program-help-and-support.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/resources/program-help-and-support.tsx
index 6debacae4f..22c5e7cbd1 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/resources/program-help-and-support.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/resources/program-help-and-support.tsx
@@ -46,9 +46,7 @@ export function ProgramHelpAndSupportContent({
const { id: workspaceId, plan } = useWorkspace();
const { partnersUpgradeModal, setShowPartnersUpgradeModal } =
- usePartnersUpgradeModal({
- plan: "Advanced",
- });
+ usePartnersUpgradeModal();
const {
control,
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/upgrade/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/upgrade/page-client.tsx
index c5f8a9d5ed..06fc7640d9 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/upgrade/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/upgrade/page-client.tsx
@@ -26,6 +26,7 @@ import {
import { isLegacyBusinessPlan } from "@dub/utils/src/constants/pricing";
import NumberFlow from "@number-flow/react";
import { ChevronLeft, ChevronRight } from "lucide-react";
+import { motion } from "motion/react";
import Link from "next/link";
import { useSearchParams } from "next/navigation";
import { CSSProperties, useEffect, useMemo, useState } from "react";
@@ -57,13 +58,11 @@ export function WorkspaceBillingUpgradePageClient() {
const [period, setPeriod] = useState<"monthly" | "yearly">("monthly");
const { partnersUpgradeModal, setShowPartnersUpgradeModal } =
- usePartnersUpgradeModal({
- plan: "Advanced",
- });
+ usePartnersUpgradeModal();
const searchParams = useSearchParams();
useEffect(() => {
- if (searchParams.get("plan") === "advanced") {
+ if (searchParams.get("showPartnersUpgradeModal")) {
setShowPartnersUpgradeModal(true);
}
}, [searchParams]);
@@ -283,103 +282,159 @@ export function WorkspaceBillingUpgradePageClient() {
/>
</div>
- <div className="h-8 bg-gradient-to-b from-white" />
+ <div className="h-4 bg-gradient-to-b from-white" />
+ </div>
+ <div className="flex flex-col pb-12">
+ {PLAN_COMPARE_FEATURES.map((section) => (
+ <BillingCompareSection
+ key={section.category}
+ category={section.category}
+ href={section.href}
+ features={section.features}
+ mobilePlanIndex={mobilePlanIndex}
+ plans={plans}
+ />
+ ))}
</div>
- <div className="flex flex-col gap-8 pb-12">
- {PLAN_COMPARE_FEATURES.map(({ category, href, features }) => {
- const Icon = COMPARE_FEATURE_ICONS[category];
+ </div>
+ </div>
+ );
+}
- return (
- <div
- key={category}
- className="w-full overflow-x-hidden [container-type:inline-size]"
- >
- <a
- href={href}
- target="_blank"
- className="flex items-center gap-2 border-b border-neutral-200 px-5 pb-4 pt-2"
- >
- {Icon && <Icon className="size-4 text-neutral-600" />}
- <h3 className="text-base font-medium text-black">
- {category}
- </h3>
- <span className="text-xs text-neutral-500">↗</span>
- </a>
- <table
- className={cn(
- "grid grid-cols-4 overflow-hidden text-sm text-neutral-800 [&_strong]:font-medium",
+function BillingCompareSection({
+ category,
+ href,
+ features,
+ mobilePlanIndex,
+ plans,
+}: (typeof PLAN_COMPARE_FEATURES)[number] & {
+ mobilePlanIndex: number;
+ plans: { plan: PlanDetails; planTier: number }[];
+}) {
+ const [isExpanded, setIsExpanded] = useState(true);
+ const { defaultProgramId } = useWorkspace();
- // Mobile
- "max-lg:w-[calc(400cqw+3*32px)] max-lg:translate-x-[calc(-1*var(--index)*(100cqw+32px))] max-lg:gap-x-8 max-lg:transition-transform",
- )}
- style={
- {
- "--index": mobilePlanIndex,
- } as CSSProperties
- }
- >
- <thead className="sr-only">
- <tr>
- {plans.map(({ plan }) => (
- <th key={plan.name}>{plan.name}</th>
- ))}
- </tr>
- </thead>
- <tbody className="contents">
- {features.map(({ check, text, href }, idx) => {
- const As = href ? "a" : "span";
+ useEffect(() => {
+ if (category === "Links") {
+ // If there's a default program, collapse Links. Otherwise expand.
+ setIsExpanded(!defaultProgramId);
+ } else if (category === "Partners") {
+ // If there's no default program, collapse Partners. Otherwise expand.
+ setIsExpanded(Boolean(defaultProgramId));
+ } else {
+ setIsExpanded(true);
+ }
+ }, [category, defaultProgramId]);
- return (
- <tr key={idx} className="contents bg-white">
- {plans.map(({ plan }) => {
- const id = plan.name.toLowerCase();
- const isChecked =
- typeof check === "boolean"
- ? check
- : check === undefined ||
- (check[id] ?? check.default ?? false);
+ const Icon = COMPARE_FEATURE_ICONS[category];
- return (
- <td
- key={id}
- className={cn(
- "flex items-center gap-2 border-b border-neutral-200 bg-white px-5 py-4",
- !isChecked && "text-neutral-300",
- )}
- >
- {isChecked ? (
- <Check className="size-3 text-neutral-500" />
- ) : (
- <span className="w-3">&bull;</span>
- )}
- <As
- href={href}
- target="_blank"
- {...(href && {
- className:
- "underline decoration-dotted underline-offset-2 cursor-help",
- })}
- >
- {typeof text === "function"
- ? (text({
- id,
- plan,
- }) as React.ReactNode)
- : text}
- </As>
- </td>
- );
- })}
- </tr>
- );
- })}
- </tbody>
- </table>
- </div>
- );
- })}
- </div>
+ return (
+ <div className="w-full overflow-x-hidden [container-type:inline-size]">
+ <div className="flex items-center justify-between border-b border-neutral-200">
+ <button
+ type="button"
+ className="group flex grow items-center gap-2 px-5 py-4 text-left"
+ onClick={() => setIsExpanded((e) => !e)}
+ >
+ <Icon className="size-4 text-neutral-600" />
+ <h3 className="text-base font-medium text-black">{category}</h3>
+ <ChevronRight
+ className={cn(
+ "size-4 text-neutral-400 transition-[transform,color] group-hover:text-neutral-500 [&_*]:stroke-2",
+ isExpanded && "rotate-90",
+ )}
+ />
+ </button>
+ {href && (
+ <Link
+ href={href}
+ target="_blank"
+ className="mr-5 cursor-alias text-xs font-medium text-neutral-500 underline decoration-dotted underline-offset-2"
+ >
+ Learn more ↗
+ </Link>
+ )}
</div>
+ <motion.div
+ initial={false}
+ animate={{ height: isExpanded ? "auto" : 0 }}
+ className={cn(
+ "overflow-clip transition-opacity",
+ !isExpanded && "opacity-0",
+ )}
+ inert={!isExpanded}
+ >
+ <table
+ className={cn(
+ "grid grid-cols-4 overflow-hidden text-sm text-neutral-800 [&_strong]:font-medium",
+
+ // Mobile
+ "max-lg:w-[calc(400cqw+3*32px)] max-lg:translate-x-[calc(-1*var(--index)*(100cqw+32px))] max-lg:gap-x-8 max-lg:transition-transform",
+ )}
+ style={
+ {
+ "--index": mobilePlanIndex,
+ } as CSSProperties
+ }
+ >
+ <thead className="sr-only">
+ <tr>
+ {plans.map(({ plan }) => (
+ <th key={plan.name}>{plan.name}</th>
+ ))}
+ </tr>
+ </thead>
+ <tbody className="contents">
+ {features.map(({ check, text, href }, idx) => {
+ const As = href ? "a" : "span";
+
+ return (
+ <tr key={idx} className="contents bg-white">
+ {plans.map(({ plan }) => {
+ const id = plan.name.toLowerCase();
+ const isChecked =
+ typeof check === "boolean"
+ ? check
+ : check === undefined ||
+ (check[id] ?? check.default ?? false);
+
+ return (
+ <td
+ key={id}
+ className={cn(
+ "flex items-center gap-2 border-b border-neutral-200 bg-white px-5 py-4",
+ !isChecked && "text-neutral-300",
+ )}
+ >
+ {isChecked ? (
+ <Check className="size-3 text-neutral-500" />
+ ) : (
+ <span className="w-3">&bull;</span>
+ )}
+ <As
+ href={href}
+ target="_blank"
+ {...(href && {
+ className:
+ "cursor-help underline decoration-dotted underline-offset-2",
+ })}
+ >
+ {typeof text === "function"
+ ? (text({
+ id,
+ plan,
+ }) as React.ReactNode)
+ : text}
+ </As>
+ </td>
+ );
+ })}
+ </tr>
+ );
+ })}
+ </tbody>
+ </table>
+ </motion.div>
</div>
);
}
diff --git a/apps/web/ui/modals/link-builder/advanced-modal.tsx b/apps/web/ui/modals/link-builder/advanced-modal.tsx
index 1f876bd383..2d9e75c674 100644
--- a/apps/web/ui/modals/link-builder/advanced-modal.tsx
+++ b/apps/web/ui/modals/link-builder/advanced-modal.tsx
@@ -12,10 +12,10 @@ import {
import { useForm, useFormContext } from "react-hook-form";
function AdvancedModal({
- showAdvancedModal,
+ showPartnersUpgradeModal,
setShowAdvancedModal,
}: {
- showAdvancedModal: boolean;
+ showPartnersUpgradeModal: boolean;
setShowAdvancedModal: Dispatch<SetStateAction<boolean>>;
}) {
const id = useId();
@@ -48,7 +48,7 @@ function AdvancedModal({
return (
<Modal
- showModal={showAdvancedModal}
+ showModal={showPartnersUpgradeModal}
setShowModal={setShowAdvancedModal}
className="sm:max-w-[500px]"
>
@@ -173,16 +173,16 @@ function AdvancedModal({
}
export function useAdvancedModal() {
- const [showAdvancedModal, setShowAdvancedModal] = useState(false);
+ const [showPartnersUpgradeModal, setShowAdvancedModal] = useState(false);
const AdvancedModalCallback = useCallback(() => {
return (
<AdvancedModal
- showAdvancedModal={showAdvancedModal}
+ showPartnersUpgradeModal={showPartnersUpgradeModal}
setShowAdvancedModal={setShowAdvancedModal}
/>
);
- }, [showAdvancedModal, setShowAdvancedModal]);
+ }, [showPartnersUpgradeModal, setShowAdvancedModal]);
return useMemo(
() => ({
diff --git a/apps/web/ui/partners/fraud-risks/partner-application-risk-summary.tsx b/apps/web/ui/partners/fraud-risks/partner-application-risk-summary.tsx
index c162e4bd57..9ab2b7312d 100644
--- a/apps/web/ui/partners/fraud-risks/partner-application-risk-summary.tsx
+++ b/apps/web/ui/partners/fraud-risks/partner-application-risk-summary.tsx
@@ -113,9 +113,7 @@ export function PartnerApplicationRiskSummaryUpsell({
severity: FraudSeverity | null | undefined;
}) {
const { partnersUpgradeModal, setShowPartnersUpgradeModal } =
- usePartnersUpgradeModal({
- plan: "Advanced",
- });
+ usePartnersUpgradeModal();
const severityConfig = severity ? APPLICATION_RISK_CONFIG[severity] : null;
diff --git a/apps/web/ui/partners/partners-upgrade-modal.tsx b/apps/web/ui/partners/partners-upgrade-modal.tsx
index b9f31a165d..1ea367bef0 100644
--- a/apps/web/ui/partners/partners-upgrade-modal.tsx
+++ b/apps/web/ui/partners/partners-upgrade-modal.tsx
@@ -149,7 +149,7 @@ export function PartnersUpgradeModal({
<Modal
showModal={showPartnersUpgradeModal}
setShowModal={setShowPartnersUpgradeModal}
- onClose={() => queryParams({ del: "plan" })}
+ onClose={() => queryParams({ del: "showPartnersUpgradeModal" })}
>
<div className="scrollbar-hide relative max-h-[calc(100dvh-50px)] overflow-y-auto p-4 sm:p-8">
<div className="pointer-events-none absolute inset-y-0 left-1/2 hidden w-[640px] -translate-x-1/2 [mask-image:linear-gradient(black,transparent_280px)] sm:block">
@@ -273,7 +273,7 @@ export function PartnersUpgradeModal({
variant="secondary"
onClick={() => {
setShowPartnersUpgradeModal(false);
- queryParams({ del: "plan" });
+ queryParams({ del: "showPartnersUpgradeModal" });
}}
/>
</div>
@@ -283,7 +283,7 @@ export function PartnersUpgradeModal({
}
export function usePartnersUpgradeModal(
- props: Omit<
+ props?: Omit<
PartnersUpgradeModalProps,
"showPartnersUpgradeModal" | "setShowPartnersUpgradeModal"
>,
diff --git a/apps/web/ui/partners/rewards/add-edit-reward-sheet.tsx b/apps/web/ui/partners/rewards/add-edit-reward-sheet.tsx
index 628cc930d3..242a891e82 100644
--- a/apps/web/ui/partners/rewards/add-edit-reward-sheet.tsx
+++ b/apps/web/ui/partners/rewards/add-edit-reward-sheet.tsx
@@ -593,7 +593,7 @@ function RewardSheetContent({
<TooltipContent
title="Advanced reward structures are only available on the Advanced plan and above."
cta="Upgrade to Advanced"
- href={`/${workspaceSlug}/upgrade?plan=advanced`}
+ href={`/${workspaceSlug}/upgrade?showPartnersUpgradeModal=true`}
target="_blank"
/>
) : undefined