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.

address rafi feedback

Steven Tey14d47c4da1ef
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/invoices/invoices-nav.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/invoices/invoices-nav.tsx
index 4380b0b4d9..93c9c6bd4c 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/invoices/invoices-nav.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/invoices/invoices-nav.tsx
@@ -5,23 +5,17 @@ import useWorkspace from "@/lib/swr/use-workspace";
import { PageNavTabs } from "@/ui/layout/page-nav-tabs";
import { CreditCard, Globe, Icon, MoneyBills2, useRouterStuff } from "@dub/ui";
-export const INVOICE_TYPES = [
- "subscription",
- "partnerPayout",
- "domainRenewal",
-] as const;
-
-export type InvoiceTypeId = (typeof INVOICE_TYPES)[number];
-
-export const INVOICE_TABS: {
- id: InvoiceTypeId;
- label: string;
- icon: Icon;
-}[] = [
+export const INVOICE_TABS = [
{ id: "subscription", label: "Subscription", icon: CreditCard },
{ id: "partnerPayout", label: "Partner payouts", icon: MoneyBills2 },
{ id: "domainRenewal", label: "Domain renewals", icon: Globe },
-];
+] as const satisfies {
+ id: string;
+ label: string;
+ icon: Icon;
+}[];
+
+export type InvoiceTypeId = (typeof INVOICE_TABS)[number]["id"];
export function getVisibleInvoiceTabs(isProduction: boolean) {
return isProduction
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/domains/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/domains/page-client.tsx
index 0d19b26667..443abd3128 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/domains/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/domains/page-client.tsx
@@ -241,9 +241,7 @@ export function CustomDomains() {
</>
)}
- {isProductionEnvironment(environment) && !dotLinkClaimed && (
- <FreeDotLinkBanner />
- )}
+ {!dotLinkClaimed && <FreeDotLinkBanner />}
<div key={archived} className="animate-fade-in">
{!loading ? (
diff --git a/apps/web/ui/domains/free-dot-link-banner.tsx b/apps/web/ui/domains/free-dot-link-banner.tsx
index 05c3bd750d..16922914cd 100644
--- a/apps/web/ui/domains/free-dot-link-banner.tsx
+++ b/apps/web/ui/domains/free-dot-link-banner.tsx
@@ -1,8 +1,9 @@
import { isProductionEnvironment } from "@/lib/sandbox/environment";
import useWorkspace from "@/lib/swr/use-workspace";
-import { Grid, useLocalStorage } from "@dub/ui";
+import { AnimatedSizeContainer, Grid, useLocalStorage } from "@dub/ui";
import { LinkBroken } from "@dub/ui/icons";
import { isWorkspaceBillingTrialActive } from "@dub/utils";
+import { useState } from "react";
import { useRegisterDomainModal } from "../modals/register-domain-modal";
import { X } from "../shared/icons";
@@ -12,63 +13,75 @@ export function FreeDotLinkBanner() {
`show-free-dot-link-banner:${workspaceId}`,
true,
);
+ // Stay mounted while the height collapses, then unmount so a dismissed
+ // banner doesn't leave an empty row in parent layouts.
+ const [collapseFinished, setCollapseFinished] = useState(!show);
const { RegisterDomainModal, setShowRegisterDomainModal } =
useRegisterDomainModal();
if (
!isProductionEnvironment(environment) ||
- isWorkspaceBillingTrialActive(trialEndsAt)
+ isWorkspaceBillingTrialActive(trialEndsAt) ||
+ (!show && collapseFinished)
) {
return null;
}
return (
- show && (
- <>
- <RegisterDomainModal />
- <div className="relative isolate flex flex-col justify-between gap-3 overflow-hidden rounded-lg border border-green-600/15 bg-gradient-to-r from-lime-100/80 to-emerald-100/80 py-3 pl-4 pr-12 sm:flex-row sm:items-center sm:py-2">
- <Grid
- cellSize={13}
- patternOffset={[0, -1]}
- className="text-black/30 mix-blend-overlay [mask-image:linear-gradient(to_right,black,transparent)] md:[mask-image:linear-gradient(to_right,black_60%,transparent)]"
- />
+ <AnimatedSizeContainer
+ height
+ transition={{ ease: "linear", duration: 0.1 }}
+ onAnimationComplete={() => {
+ if (!show) setCollapseFinished(true);
+ }}
+ >
+ {show && (
+ <>
+ <RegisterDomainModal />
+ <div className="relative isolate flex flex-col justify-between gap-3 overflow-hidden rounded-lg border border-green-600/15 bg-gradient-to-r from-lime-100/80 to-emerald-100/80 py-3 pl-4 pr-12 sm:flex-row sm:items-center sm:py-2">
+ <Grid
+ cellSize={13}
+ patternOffset={[0, -1]}
+ className="text-black/30 mix-blend-overlay [mask-image:linear-gradient(to_right,black,transparent)] md:[mask-image:linear-gradient(to_right,black_60%,transparent)]"
+ />
- <div className="flex items-center gap-3">
- <div className="hidden rounded-full border border-green-600/50 bg-white/50 p-1 shadow-[inset_0_0_1px_1px_#fff] sm:block">
- <LinkBroken className="m-px size-4 text-green-800" />
+ <div className="flex items-center gap-3">
+ <div className="hidden rounded-full border border-green-600/50 bg-white/50 p-1 shadow-[inset_0_0_1px_1px_#fff] sm:block">
+ <LinkBroken className="m-px size-4 text-green-800" />
+ </div>
+ <p className="text-sm text-neutral-900">
+ Claim a free <span className="font-semibold">.link</span> domain,
+ free for 1 year.{" "}
+ <a
+ href="https://dub.co/help/article/free-dot-link-domain"
+ target="_blank"
+ className="text-neutral-700 underline transition-colors hover:text-black"
+ >
+ Learn more
+ </a>
+ </p>
</div>
- <p className="text-sm text-neutral-900">
- Claim a free <span className="font-semibold">.link</span> domain,
- free for 1 year.{" "}
- <a
- href="https://dub.co/help/article/free-dot-link-domain"
- target="_blank"
- className="text-neutral-700 underline transition-colors hover:text-black"
- >
- Learn more
- </a>
- </p>
- </div>
- <div className="flex items-center sm:-my-1">
+ <div className="flex items-center sm:-my-1">
+ <button
+ type="button"
+ className="whitespace-nowrap rounded-md border border-green-700/50 px-3 py-1 text-sm text-neutral-800 transition-colors hover:bg-green-500/10"
+ onClick={() => setShowRegisterDomainModal(true)}
+ >
+ Claim Domain
+ </button>
+ </div>
<button
type="button"
- className="whitespace-nowrap rounded-md border border-green-700/50 px-3 py-1 text-sm text-neutral-800 transition-colors hover:bg-green-500/10"
- onClick={() => setShowRegisterDomainModal(true)}
+ className="absolute right-2.5 top-2.5 p-1 text-sm text-green-700 underline transition-colors hover:text-green-900 sm:top-1/2 sm:-translate-y-1/2"
+ onClick={() => setShow(false)}
>
- Claim Domain
+ <X className="size-[18px]" />
</button>
</div>
- <button
- type="button"
- className="absolute right-2.5 top-2.5 p-1 text-sm text-green-700 underline transition-colors hover:text-green-900 sm:top-1/2 sm:-translate-y-1/2"
- onClick={() => setShow(false)}
- >
- <X className="size-[18px]" />
- </button>
- </div>
- </>
- )
+ </>
+ )}
+ </AnimatedSizeContainer>
);
}
diff --git a/apps/web/ui/links/short-link-input.tsx b/apps/web/ui/links/short-link-input.tsx
index 644989576e..e2bc76321d 100644
--- a/apps/web/ui/links/short-link-input.tsx
+++ b/apps/web/ui/links/short-link-input.tsx
@@ -1,12 +1,10 @@
"use client";
-import { isProductionEnvironment } from "@/lib/sandbox/environment";
import useWorkspace from "@/lib/swr/use-workspace";
import { LinkProps } from "@/lib/types";
import { DOMAINS_MAX_PAGE_SIZE } from "@/lib/zod/schemas/domains";
import { useCompletion } from "@ai-sdk/react";
import {
- AnimatedSizeContainer,
ArrowTurnRight2,
ButtonTooltip,
Combobox,
@@ -89,7 +87,6 @@ export const ShortLinkInput = forwardRef<HTMLInputElement, ShortLinkInputProps>(
exceededAI,
nextPlan,
dotLinkClaimed,
- environment,
} = useWorkspace();
const [lockKey, setLockKey] = useState(existingLink);
@@ -412,17 +409,11 @@ export const ShortLinkInput = forwardRef<HTMLInputElement, ShortLinkInputProps>(
onChange={(domain) => onChange({ domain })}
/>
)}
- {!onboarding &&
- !dotLinkClaimed &&
- isProductionEnvironment(environment) && (
- <AnimatedSizeContainer
- height
- transition={{ ease: "linear", duration: 0.1 }}
- className="mt-2"
- >
- <FreeDotLinkBanner />
- </AnimatedSizeContainer>
- )}
+ {!onboarding && !dotLinkClaimed && (
+ <div className="mt-2">
+ <FreeDotLinkBanner />
+ </div>
+ )}
</div>
);
},