The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
update domain modals
Steven Teyc405bb847d83
diff --git a/apps/web/lib/types.ts b/apps/web/lib/types.tsindex e437c6e129..51d19799b7 100644--- a/apps/web/lib/types.ts+++ b/apps/web/lib/types.ts@@ -235,6 +235,7 @@ export interface RegisteredDomainProps {autoRenewalDisabledAt: Date | null;createdAt: Date;expiresAt: Date;+ renewalFee: number;}export interface BitlyGroupProps {diff --git a/apps/web/lib/zod/schemas/domains.ts b/apps/web/lib/zod/schemas/domains.tsindex 4c51372076..2e6969636f 100644--- a/apps/web/lib/zod/schemas/domains.ts+++ b/apps/web/lib/zod/schemas/domains.ts@@ -15,6 +15,7 @@ export const RegisteredDomainSchema = z.object({.describe("The date the domain auto-renew is disabled."),createdAt: z.date().describe("The date the domain was created."),expiresAt: z.date().describe("The date the domain expires."),+ renewalFee: z.number().describe("The fee to renew the domain."),});export const DomainSchema = z.object({diff --git a/apps/web/ui/domains/domain-card.tsx b/apps/web/ui/domains/domain-card.tsxindex 0a2d61d08a..513b939826 100644--- a/apps/web/ui/domains/domain-card.tsx+++ b/apps/web/ui/domains/domain-card.tsx@@ -22,6 +22,7 @@ import {Wordmark,} from "@dub/ui";import {+ CircleHalfDottedClock,CursorRays,Flag2,Gear,@@ -104,8 +105,32 @@ export default function DomainCard({ props }: { props: DomainProps }) {const expiresAt = props.registeredDomain?.expiresAt;const isExpired = expiresAt && isPast(new Date(expiresAt));+ const autoRenew = useMemo(() => {+ if (!registeredDomain) {+ return false;+ }++ return registeredDomain.autoRenewalDisabledAt === null;+ }, [registeredDomain]);++ const { setShowEnableAutoRenewalModal, EnableAutoRenewalModal } =+ useEnableAutoRenewalModal({+ domain: props,+ });++ const { setShowDisableAutoRenewalModal, DisableAutoRenewalModal } =+ useDisableAutoRenewalModal({+ domain: props,+ });+return (<>+ {isDubProvisioned && (+ <>+ <EnableAutoRenewalModal />+ <DisableAutoRenewalModal />+ </>+ )}<divref={domainRef}className="hover:drop-shadow-card-hover group rounded-xl border border-neutral-200 bg-white transition-[filter]"@@ -123,19 +148,34 @@ export default function DomainCard({ props }: { props: DomainProps }) {</div>{expiresAt && (- <div+ <buttonclassName={cn(- "flex items-center gap-1",- isExpired ? "text-red-600" : "text-neutral-700",+ "flex items-center gap-1 decoration-dotted underline-offset-2 hover:underline",+ isExpired+ ? "text-red-600"+ : autoRenew+ ? "text-neutral-700"+ : "text-neutral-400 hover:text-neutral-700",)}+ onClick={() => {+ if (!autoRenew) {+ setShowEnableAutoRenewalModal(true);+ } else {+ setShowDisableAutoRenewalModal(true);+ }+ }}>- <Repeat className="size-3.5" />+ {autoRenew ? (+ <Repeat className="size-3.5" />+ ) : (+ <CircleHalfDottedClock className="size-3.5" />+ )}<span className="text-xs font-medium">- {isExpired- ? `Expired on ${formatDate(expiresAt)}`- : `Renews on ${formatDate(expiresAt)}`}+ {autoRenew+ ? `Renews on ${formatDate(expiresAt)}`+ : `Expire${isExpired ? "d" : "s"} on ${formatDate(expiresAt)}`}</span>- </div>+ </button>)}</div>@@ -244,11 +284,14 @@ export default function DomainCard({ props }: { props: DomainProps }) {data-state={showDetails ? "open" : "closed"}/>)}- <Menu+ <DomainCardMenuprops={props}linkProps={props.link}refreshProps={{ isValidating, mutate }}groupHover={groupHover}+ autoRenew={autoRenew}+ setShowEnableAutoRenewalModal={setShowEnableAutoRenewalModal}+ setShowDisableAutoRenewalModal={setShowDisableAutoRenewalModal}/></div></div>@@ -286,11 +329,14 @@ export default function DomainCard({ props }: { props: DomainProps }) {);}-function Menu({+function DomainCardMenu({props,linkProps,refreshProps,groupHover,+ autoRenew,+ setShowEnableAutoRenewalModal,+ setShowDisableAutoRenewalModal,}: {props: DomainProps;linkProps?: LinkProps;@@ -299,6 +345,9 @@ function Menu({mutate: () => void;};groupHover: boolean;+ autoRenew: boolean;+ setShowEnableAutoRenewalModal: (show: boolean) => void;+ setShowDisableAutoRenewalModal: (show: boolean) => void;}) {const { role } = useWorkspace();const { isMobile } = useMediaQuery();@@ -309,14 +358,6 @@ function Menu({const { primary, archived, slug: domain, registeredDomain } = props;const isDubProvisioned = !!registeredDomain;- const autoRenew = useMemo(() => {- if (!registeredDomain) {- return false;- }-- return registeredDomain.autoRenewalDisabledAt === null;- }, [registeredDomain]);-const permissionsError = clientAccessCheck({action: "domains.write",role,@@ -354,16 +395,6 @@ function Menu({props: linkProps || DEFAULT_LINK_PROPS,});- const { setShowEnableAutoRenewalModal, EnableAutoRenewalModal } =- useEnableAutoRenewalModal({- domain: props,- });-- const { setShowDisableAutoRenewalModal, DisableAutoRenewalModal } =- useDisableAutoRenewalModal({- domain: props,- });-const copyLinkId = () => {if (!linkProps) {toast.error("Link ID not found");@@ -385,14 +416,6 @@ function Menu({<ArchiveDomainModal /><DeleteDomainModal /><TransferDomainModal />-- {isDubProvisioned && (- <>- <EnableAutoRenewalModal />- <DisableAutoRenewalModal />- </>- )}-<motion.divanimate={{width: groupHover && !isMobile ? "auto" : isMobile ? 79 : 39,diff --git a/apps/web/ui/modals/disable-auto-renewal-modal.tsx b/apps/web/ui/modals/disable-auto-renewal-modal.tsxindex 82e7da2379..037c42c845 100644--- a/apps/web/ui/modals/disable-auto-renewal-modal.tsx+++ b/apps/web/ui/modals/disable-auto-renewal-modal.tsx@@ -75,7 +75,7 @@ function DisableAutoRenewalModal({<br /><br />Once your domain expires, there is no guarantee that you’ll be able to- get it back. To avoid that, turn auto-renewal back on.+ get it back. Please proceed with caution.</p><div className="scrollbar-hide mt-4 flex max-h-[190px] flex-col gap-2 overflow-y-auto">@@ -85,13 +85,7 @@ function DisableAutoRenewalModal({<Globe className="size-5" /></div></div>- <div className="overflow-hidden">- <div className="flex items-center gap-1.5 sm:gap-2.5">- <span className="truncate text-sm font-medium">- {domain.slug}- </span>- </div>- </div>+ <span className="truncate text-sm font-medium">{domain.slug}</span></div></div></div>@@ -107,7 +101,7 @@ function DisableAutoRenewalModal({onClick={disableAutoRenewal}autoFocusloading={isSubmitting}- text="Confirm"+ text="Disable auto-renewal"className="h-8 w-fit px-3"/></div>diff --git a/apps/web/ui/modals/enable-auto-renewal-modal.tsx b/apps/web/ui/modals/enable-auto-renewal-modal.tsxindex daebbd27e4..a8c7251f80 100644--- a/apps/web/ui/modals/enable-auto-renewal-modal.tsx+++ b/apps/web/ui/modals/enable-auto-renewal-modal.tsx@@ -3,6 +3,7 @@ import useWorkspace from "@/lib/swr/use-workspace";import { DomainProps } from "@/lib/types";import { Button, Modal } from "@dub/ui";import { Globe } from "@dub/ui/icons";+import { currencyFormatter, formatDate } from "@dub/utils";import {Dispatch,SetStateAction,@@ -68,7 +69,9 @@ function EnableAutoRenewalModal({<div className="bg-neutral-50 p-4 sm:p-6"><p className="text-sm text-neutral-800">- This domain will renew each year for $12.+ By enabling auto-renewal, Dub will automatically renew your domain on{" "}+ <strong>{formatDate(domain.registeredDomain?.expiresAt!)}</strong> for{" "}+ {currencyFormatter(domain.registeredDomain?.renewalFee! / 100)}.</p><div className="scrollbar-hide mt-4 flex max-h-[190px] flex-col gap-2 overflow-y-auto">@@ -78,13 +81,7 @@ function EnableAutoRenewalModal({<Globe className="size-5" /></div></div>- <div className="overflow-hidden">- <div className="flex items-center gap-1.5 sm:gap-2.5">- <span className="truncate text-sm font-medium">- {domain.slug}- </span>- </div>- </div>+ <span className="truncate text-sm font-medium">{domain.slug}</span></div></div></div>@@ -100,7 +97,7 @@ function EnableAutoRenewalModal({onClick={enableAutoRenewal}autoFocusloading={isSubmitting}- text="Confirm"+ text="Enable auto-renewal"className="h-8 w-fit px-3"/></div>