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.

optimize claim domain

Steven Tey3fbc36e6e547
diff --git a/apps/web/lib/api/domains/claim-dot-link-domain.ts b/apps/web/lib/api/domains/claim-dot-link-domain.ts
index 758a07e5b9..b5c718889d 100644
--- a/apps/web/lib/api/domains/claim-dot-link-domain.ts
+++ b/apps/web/lib/api/domains/claim-dot-link-domain.ts
@@ -31,6 +31,13 @@ export async function claimDotLinkDomain({
message: "Free workspaces cannot register .link domains.",
});
+ if (!workspace.stripeId) {
+ throw new DubApiError({
+ code: "forbidden",
+ message: "You cannot register a .link domain on a free trial.",
+ });
+ }
+
if (workspace.id !== ACME_WORKSPACE_ID && workspace.dotLinkClaimed) {
throw new DubApiError({
code: "forbidden",
diff --git a/apps/web/ui/domains/register-domain-form.tsx b/apps/web/ui/domains/register-domain-form.tsx
index b7f8d908c0..70e281b6a0 100644
--- a/apps/web/ui/domains/register-domain-form.tsx
+++ b/apps/web/ui/domains/register-domain-form.tsx
@@ -129,6 +129,8 @@ export function RegisterDomainForm({
<form
onSubmit={async (e: FormEvent<HTMLFormElement>) => {
e.preventDefault();
+ // prevent the submission event from propagating to the parent form (in the link builder)
+ e.stopPropagation();
if (searchedDomain && searchedDomain.available) {
await registerDomain(searchedDomain.domain);
}