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.

update AddEditDomainForm to use latest design + useForm

Steven Teydfa8a461db97
diff --git a/apps/web/lib/zod/schemas/domains.ts b/apps/web/lib/zod/schemas/domains.ts
index c5247f01f6..761bfe8b42 100644
--- a/apps/web/lib/zod/schemas/domains.ts
+++ b/apps/web/lib/zod/schemas/domains.ts
@@ -119,7 +119,7 @@ export const createDomainBodySchema = z.object({
"Provide context to your teammates in the link creation modal by showing them an example of a link to be shortened.",
)
.openapi({ example: "https://dub.co/help/article/what-is-dub" }),
- logo: z.string().url().nullish().describe("The logo of the domain."),
+ logo: z.string().nullish().describe("The logo of the domain."),
});
export const updateDomainBodySchema = createDomainBodySchema.partial();
diff --git a/apps/web/package.json b/apps/web/package.json
index 0d9fde9d43..01cff66006 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -75,7 +75,7 @@
"js-cookie": "^3.0.5",
"json-2-csv": "^5.5.0",
"jszip": "^3.10.1",
- "lucide-react": "^0.367.0",
+ "lucide-react": "^0.462.0",
"nanoid": "^5.0.1",
"next": "14.3.0-canary.42",
"next-auth": "^4.24.4",
diff --git a/apps/web/ui/domains/add-edit-domain-form.tsx b/apps/web/ui/domains/add-edit-domain-form.tsx
index 96da3be957..acdaf48010 100644
--- a/apps/web/ui/domains/add-edit-domain-form.tsx
+++ b/apps/web/ui/domains/add-edit-domain-form.tsx
@@ -1,23 +1,40 @@
import useWorkspace from "@/lib/swr/use-workspace";
import { DomainProps } from "@/lib/types";
-import { Lock } from "@/ui/shared/icons";
-import { ProBadgeTooltip } from "@/ui/shared/pro-badge-tooltip";
+import { AlertCircleFill, CheckCircleFill, Lock } from "@/ui/shared/icons";
import { UpgradeRequiredToast } from "@/ui/shared/upgrade-required-toast";
import {
- BlurImage,
+ AnimatedSizeContainer,
+ Badge,
Button,
- FileUpload,
InfoTooltip,
+ LoadingSpinner,
SimpleTooltipContent,
Switch,
+ useMediaQuery,
} from "@dub/ui";
import { cn } from "@dub/utils";
import { motion } from "framer-motion";
+import {
+ Binoculars,
+ Crown,
+ Milestone,
+ QrCode,
+ TextCursorInput,
+} from "lucide-react";
import posthog from "posthog-js";
import { useMemo, useState } from "react";
+import { useForm } from "react-hook-form";
import { toast } from "sonner";
import { mutate } from "swr";
-import DomainInput from "./domain-input";
+import { z } from "zod";
+
+const domainFormSchema = z.object({
+ slug: z.string().min(1, "Domain is required"),
+ logo: z.string().optional(),
+ expiredUrl: z.string().url().optional().or(z.literal("")),
+ notFoundUrl: z.string().url().optional().or(z.literal("")),
+ placeholder: z.string().url().optional().or(z.literal("")),
+});
export function AddEditDomainForm({
props,
@@ -31,45 +48,33 @@ export function AddEditDomainForm({
className?: string;
}) {
const { id: workspaceId, plan } = useWorkspace();
-
const isDubProvisioned = !!props?.registeredDomain;
+ const [lockDomain, setLockDomain] = useState(true);
+ const [domainStatus, setDomainStatus] = useState<
+ "checking" | "conflict" | "has site" | "available" | null
+ >(props ? "available" : null);
- const [data, setData] = useState<DomainProps>(
- props || {
- id: "",
- slug: "",
- verified: false,
- primary: false,
- archived: false,
- projectId: workspaceId || "",
- logo: "",
+ const {
+ register,
+ handleSubmit,
+ watch,
+ setValue,
+ formState: { isSubmitting, isDirty },
+ } = useForm<z.infer<typeof domainFormSchema>>({
+ defaultValues: {
+ slug: props?.slug || "",
+ logo: props?.logo || "",
+ expiredUrl: props?.expiredUrl || "",
+ notFoundUrl: props?.notFoundUrl || "",
+ placeholder: props?.placeholder || "",
},
- );
+ });
- const { slug: domain, placeholder, expiredUrl, notFoundUrl, logo } = data;
-
- const [lockDomain, setLockDomain] = useState(true);
- const [saving, setSaving] = useState(false);
- const [domainError, setDomainError] = useState<string | null>(null);
+ const domain = watch("slug");
const saveDisabled = useMemo(() => {
- /*
- Disable save if:
- - saving is in progress
- - domain is invalid
- - for an existing domain, there's no changes
- */
- if (
- saving ||
- domainError ||
- (props &&
- Object.entries(props).every(([key, value]) => data[key] === value))
- ) {
- return true;
- } else {
- return false;
- }
- }, [saving, domainError, props, data]);
+ return isSubmitting || domainStatus !== "available" || (props && !isDirty);
+ }, [isSubmitting, domainStatus, props, isDirty]);
const endpoint = useMemo(() => {
if (props) {
@@ -87,98 +92,63 @@ export function AddEditDomainForm({
}
}, [props, workspaceId]);
- const [showDefaultExpirationUrl, setShowDefaultExpirationUrl] = useState(
- !!data.expiredUrl,
- );
- const [showNotFoundUrl, setShowNotFoundUrl] = useState(!!data.notFoundUrl);
+ const { isMobile } = useMediaQuery();
- const [showPlaceholderUrl, setShowPlaceholderUrl] = useState(
- !!data.placeholder,
- );
+ const onSubmit = async (formData: z.infer<typeof domainFormSchema>) => {
+ try {
+ const res = await fetch(endpoint.url, {
+ method: endpoint.method,
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify(formData),
+ });
+
+ if (res.ok) {
+ await Promise.all([
+ mutate(
+ (key) => typeof key === "string" && key.startsWith("/api/domains"),
+ ),
+ mutate(
+ (key) => typeof key === "string" && key.startsWith("/api/links"),
+ undefined,
+ { revalidate: true },
+ ),
+ ]);
+ const data = await res.json();
+ posthog.capture(props ? "domain_updated" : "domain_created", data);
+ toast.success(endpoint.successMessage);
+ onSuccess?.(data);
+ } else {
+ const { error } = await res.json();
+ if (res.status === 422) {
+ setDomainStatus("conflict");
+ }
+ if (error.message.includes("Upgrade to Pro")) {
+ toast.custom(() => (
+ <UpgradeRequiredToast
+ title="You've discovered a Pro feature!"
+ message={error.message}
+ />
+ ));
+ } else {
+ toast.error(error.message);
+ }
+ }
+ } catch (error) {
+ toast.error("Failed to add domain");
+ }
+ };
return (
<form
- onSubmit={async (e) => {
- e.preventDefault();
- setSaving(true);
- fetch(endpoint.url, {
- method: endpoint.method,
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify(data),
- })
- .then(async (res) => {
- if (res.ok) {
- await Promise.all([
- mutate(
- (key) =>
- typeof key === "string" && key.startsWith("/api/domains"),
- ),
- mutate(
- (key) =>
- typeof key === "string" && key.startsWith("/api/links"),
- undefined,
- { revalidate: true },
- ),
- ]);
- const data = await res.json();
- posthog.capture(
- props ? "domain_updated" : "domain_created",
- data,
- );
- toast.success(endpoint.successMessage);
- onSuccess?.(data);
- } else {
- setSaving(false);
- const { error } = await res.json();
- if (res.status === 422) {
- setDomainError(error.message);
- }
- if (error.message.includes("Upgrade to Pro")) {
- toast.custom(() => (
- <UpgradeRequiredToast
- title="You've discovered a Pro feature!"
- message={error.message}
- />
- ));
- } else {
- toast.error(error.message);
- }
- }
- })
- .catch(() => {
- setSaving(false);
- toast.error("Failed to add domain");
- });
- }}
+ onSubmit={handleSubmit(onSubmit)}
className={cn("flex flex-col gap-y-6 text-left", className)}
>
<div>
- <div className="mb-4 flex flex-col items-center justify-center gap-2">
- <FileUpload
- accept="images"
- className="h-20 w-20 rounded-full border border-gray-300"
- iconClassName="w-5 h-5"
- variant="plain"
- imageSrc={logo}
- readFile
- onChange={({ src }) => {
- setData((d) => ({ ...d, logo: src }));
- }}
- content={null}
- maxFileSizeMB={2}
- targetResolution={{ width: 240, height: 240 }}
- disabled={plan === "free"}
- />
- <div>
- <ProBadgeTooltip content="Upload a custom logo to use on QR codes for links under this domain." />
- </div>
- </div>
-
<div className="flex items-center justify-between">
<label htmlFor="domain" className="flex items-center gap-x-2">
- <h2 className="text-sm font-medium text-gray-700">Domain</h2>
+ <h2 className="text-sm font-medium text-gray-700">Your domain</h2>
<InfoTooltip
content={
<SimpleTooltipContent
@@ -209,163 +179,198 @@ export function AddEditDomainForm({
{domain}
</div>
) : (
- <DomainInput
- identifier="slug"
- data={data}
- setData={setData}
- domainError={domainError}
- setDomainError={setDomainError}
- />
- )}
- </div>
-
- {showAdvancedOptions && (
- <div className="flex flex-col gap-y-6">
- <div>
- <label className="flex items-center justify-between gap-2">
- <div className="flex items-center gap-2">
- <h2 className="text-sm font-medium text-gray-900">
- Default Expiration URL
- </h2>
- <ProBadgeTooltip
- content={
- <SimpleTooltipContent
- title="Redirect users to a specific URL when any link under this domain has expired."
- cta="Learn more."
- href="https://dub.co/help/article/link-expiration#setting-a-default-expiration-url-for-all-links-under-a-domain"
- />
- }
- />
- </div>
- <Switch
- checked={showDefaultExpirationUrl}
- fn={(checked) => {
- setShowDefaultExpirationUrl(checked);
- if (!checked) setData((d) => ({ ...d, expiredUrl: "" }));
- }}
- />
- </label>
- <motion.div
- animate={{ height: showDefaultExpirationUrl ? "auto" : 0 }}
- transition={{ duration: 0.1 }}
- initial={false}
- className="-m-1 overflow-hidden p-1"
+ <div className="mt-2">
+ <div
+ className={cn(
+ "-m-1 rounded-[0.625rem] p-1",
+ domainStatus === "conflict"
+ ? "bg-orange-100 text-orange-800"
+ : domainStatus === "available"
+ ? "bg-green-100 text-green-800"
+ : "bg-gray-200 text-gray-500",
+ )}
>
- <div className="relative mt-2 rounded-md shadow-sm">
+ <div className="flex rounded-md border border-gray-300 bg-white">
<input
- name="expiredUrl"
- id="expiredUrl"
- className="block w-full rounded-md border-gray-300 text-gray-900 placeholder-gray-400 focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm"
- placeholder="https://yourwebsite.com"
- value={expiredUrl}
- onChange={(e) =>
- setData((d) => ({ ...d, expiredUrl: e.target.value }))
- }
+ {...register("slug", {
+ onChange: (e) => {
+ if (e.target.value.trim()) {
+ setDomainStatus("checking");
+ } else {
+ setDomainStatus(null);
+ }
+ },
+ onBlur: (e) => {
+ if (
+ e.target.value.length > 0 &&
+ e.target.value.toLowerCase() !==
+ props?.slug.toLowerCase()
+ ) {
+ fetch(`/api/domains/${e.target.value}/exists`).then(
+ async (res) => {
+ const exists = await res.json();
+ setDomainStatus(
+ exists === 1 ? "conflict" : "available",
+ );
+ },
+ );
+ }
+ },
+ })}
+ className="block w-full rounded-md border-0 text-gray-900 placeholder-gray-400 focus:outline-none focus:ring-0 sm:text-sm"
+ placeholder="go.acme.com"
+ autoFocus={!isMobile}
/>
</div>
- </motion.div>
- </div>
- <div>
- <label className="flex items-center justify-between gap-2">
- <div className="flex items-center gap-2">
- <h2 className="text-sm font-medium text-gray-900">
- Not Found URL
- </h2>
- <ProBadgeTooltip content="Redirect users to a specific URL when a link under this domain doesn't exist." />
- </div>
- <Switch
- checked={showNotFoundUrl}
- fn={(checked) => {
- setShowNotFoundUrl(checked);
- if (!checked) setData((d) => ({ ...d, notFoundUrl: "" }));
- }}
- />
- </label>
- <motion.div
- animate={{ height: showNotFoundUrl ? "auto" : 0 }}
- transition={{ duration: 0.1 }}
- initial={false}
- className="-m-1 overflow-hidden p-1"
- >
- <div className="relative mt-2 rounded-md shadow-sm">
- <input
- name="notFoundUrl"
- id="notFoundUrl"
- className="block w-full rounded-md border-gray-300 text-gray-900 placeholder-gray-400 focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm"
- placeholder="https://yourwebsite.com"
- value={notFoundUrl}
- onChange={(e) =>
- setData((d) => ({ ...d, notFoundUrl: e.target.value }))
- }
- />
- </div>
- </motion.div>
+ <AnimatedSizeContainer
+ height
+ transition={{ ease: "easeInOut", duration: 0.1 }}
+ >
+ <div className="flex justify-between gap-3 p-2 text-sm">
+ <p>
+ {domainStatus === "checking" ? (
+ <>
+ Checking availability for{" "}
+ <strong className="font-semibold underline underline-offset-2">
+ {domain}
+ </strong>
+ ...
+ </>
+ ) : domainStatus === "conflict" ? (
+ <>
+ The domain{" "}
+ <span className="font-semibold underline underline-offset-2">
+ {domain}
+ </span>{" "}
+ is already in use.
+ </>
+ ) : domainStatus === "available" ? (
+ <>
+ The domain{" "}
+ <span className="font-semibold underline underline-offset-2">
+ {domain}
+ </span>{" "}
+ looks clear to connect.
+ </>
+ ) : (
+ "Your domain will be used for shortlinks on Dub, and cannot be used for anything else while connected."
+ )}
+ </p>
+ {domainStatus === "checking" ? (
+ <LoadingSpinner className="mr-0.5 mt-0.5 size-4 shrink-0" />
+ ) : domainStatus === "conflict" ? (
+ <AlertCircleFill className="size-5 shrink-0 text-orange-500" />
+ ) : domainStatus === "available" ? (
+ <CheckCircleFill className="size-5 shrink-0 text-green-500" />
+ ) : null}
+ </div>
+ </AnimatedSizeContainer>
+ </div>
</div>
+ )}
+ </div>
- <div>
- <label className="flex items-center justify-between gap-2">
- <div className="flex items-center gap-2">
- <h2 className="text-sm font-medium text-gray-900">
- Input Placeholder URL
- </h2>
- <InfoTooltip
- content={
- <div className="flex max-w-sm flex-col items-center justify-center">
- <div className="border-b border-gray-200">
- <BlurImage
- src="https://assets.dub.co/help/domain-input-placeholder-url.png"
- alt="Input Placeholder URL"
- className="aspect-[782/506]"
- width={782}
- height={506}
+ {showAdvancedOptions && (
+ <>
+ <div className="h-0.5 w-full bg-gray-200" />
+ <div className="flex flex-col gap-y-6">
+ {ADVANCED_OPTIONS.map(
+ ({ id, title, description, icon: Icon, proFeature }) => {
+ const [showOption, setShowOption] = useState(
+ !!watch(id as keyof z.infer<typeof domainFormSchema>),
+ );
+ return (
+ <div key={id}>
+ <label className="flex items-center justify-between gap-2">
+ <div className="flex items-center gap-3">
+ <div className="rounded-lg border border-gray-200 bg-white p-2">
+ <Icon className="size-5 text-gray-600" />
+ </div>
+ <div>
+ <div className="flex items-center gap-2">
+ <h2 className="text-sm font-medium text-gray-900">
+ {title}
+ </h2>
+ {proFeature && plan === "free" && (
+ <Badge className="flex items-center space-x-1 bg-white">
+ <Crown size={12} />
+ <p className="uppercase">Pro</p>
+ </Badge>
+ )}
+ </div>
+ <p className="text-sm text-gray-500">{description}</p>
+ </div>
+ </div>
+ <Switch
+ checked={showOption}
+ fn={(checked) => {
+ setShowOption(checked);
+ if (!checked)
+ setValue(
+ id as keyof z.infer<typeof domainFormSchema>,
+ "",
+ );
+ }}
+ />
+ </label>
+ <motion.div
+ animate={{ height: showOption ? "auto" : 0 }}
+ transition={{ duration: 0.1 }}
+ initial={false}
+ className="-m-1 overflow-hidden p-1"
+ >
+ <div className="relative mt-2 rounded-md shadow-sm">
+ <input
+ {...register(
+ id as keyof z.infer<typeof domainFormSchema>,
+ )}
+ className="block w-full rounded-md border-gray-300 text-gray-900 placeholder-gray-400 focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm"
+ placeholder="https://yourwebsite.com"
/>
</div>
- <p className="max-w-xs px-4 py-2 text-center text-sm text-gray-700">
- Provide context to your teammates in the link creation
- modal by showing them an example of a link to be
- shortened.
- </p>
- </div>
- }
- side="right"
- />
- </div>
- <Switch
- checked={showPlaceholderUrl}
- fn={(checked) => {
- setShowPlaceholderUrl(checked);
- if (!checked) setData((d) => ({ ...d, placeholder: "" }));
- }}
- />
- </label>
- <motion.div
- animate={{ height: showPlaceholderUrl ? "auto" : 0 }}
- transition={{ duration: 0.1 }}
- initial={false}
- className="-m-1 overflow-hidden p-1"
- >
- <div className="relative mt-2 rounded-md shadow-sm">
- <input
- name="placeholder"
- id="placeholder"
- className="block w-full rounded-md border-gray-300 text-gray-900 placeholder-gray-400 focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm"
- placeholder="https://dub.co/help/article/what-is-dub"
- value={placeholder}
- onChange={(e) =>
- setData((d) => ({ ...d, placeholder: e.target.value }))
- }
- />
- </div>
- </motion.div>
+ </motion.div>
+ </div>
+ );
+ },
+ )}
</div>
- </div>
+ </>
)}
+
<Button
text={props ? "Save changes" : "Add domain"}
disabled={saveDisabled}
- loading={saving}
+ loading={isSubmitting}
/>
</form>
);
}
+
+const ADVANCED_OPTIONS = [
+ {
+ id: "logo",
+ title: "Custom QR code logo",
+ description: "Set a custom logo for shortlink QR codes",
+ icon: QrCode,
+ proFeature: true,
+ },
+ {
+ id: "expiredUrl",
+ title: "Default expiration URL",
+ description: "Redirects when the shortlink has expired",
+ icon: Milestone,
+ },
+ {
+ id: "notFoundUrl",
+ title: "Not found URL",
+ description: "Redirects when the shortlink doesn't exist",
+ icon: Binoculars,
+ },
+ {
+ id: "placeholder",
+ title: "Input placeholder URL",
+ description: "Set a placeholder URL for the link builder",
+ icon: TextCursorInput,
+ },
+];
diff --git a/apps/web/ui/domains/domain-input.tsx b/apps/web/ui/domains/domain-input.tsx
deleted file mode 100644
index e1045b7e4f..0000000000
--- a/apps/web/ui/domains/domain-input.tsx
+++ /dev/null
@@ -1,145 +0,0 @@
-import { AlertCircleFill, CheckCircleFill } from "@/ui/shared/icons";
-import { useMediaQuery } from "@dub/ui";
-import { cn, getApexDomain, getSubdomain, getUrlFromString } from "@dub/utils";
-import { useEffect, useMemo, useRef, useState } from "react";
-
-export default function DomainInput({
- identifier = "domain", // "domain" is the default, but when it's used in AddEditDomainModal, it's "slug"
- data,
- setData,
- domainError,
- setDomainError,
-}) {
- const domain = data[identifier];
- const originalDomain = useMemo(() => domain, []);
-
- const [domainType, setDomainType] = useState<string | undefined>(undefined);
- const apexDomain = useMemo(
- () => getApexDomain(getUrlFromString(domain)),
- [domain],
- );
-
- const { isMobile } = useMediaQuery();
- const domainRef = useRef<HTMLInputElement>(null);
- const subdomainRef = useRef<HTMLInputElement>(null);
-
- useEffect(() => {
- if (domainType === "website") {
- subdomainRef.current?.focus();
- }
- }, [domainType]);
-
- return (
- <>
- <div className="relative mt-2 flex rounded-md shadow-sm">
- {domainType === "website" ? (
- <div className="relative flex w-full rounded-md shadow-sm">
- <input
- ref={subdomainRef}
- name="subdomain"
- id="subdomain"
- type="text"
- required
- autoComplete="off"
- placeholder="subdomain"
- className="w-1/3 rounded-l-md border-gray-300 text-gray-900 placeholder-gray-400 focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm"
- value={getSubdomain(domain, apexDomain) || ""}
- onChange={(e) => {
- setData({
- ...data,
- [identifier]: `${e.target.value}.${apexDomain}`,
- });
- }}
- aria-invalid="true"
- />
- <span className="inline-flex flex-1 items-center rounded-r-md border border-l-0 border-gray-300 bg-gray-50 px-3 text-gray-500 sm:text-sm">
- .{apexDomain}
- </span>
- </div>
- ) : (
- <input
- ref={domainRef}
- name="domain"
- id="domain"
- type="text"
- required
- autoFocus={!isMobile && identifier === "slug"}
- autoComplete="off"
- pattern="[a-zA-Z0-9\-.]+"
- className={cn(
- "block w-full rounded-md border-gray-300 text-gray-900 placeholder-gray-400 focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm",
- {
- "border-red-300 pr-10 text-red-900 placeholder-red-300 focus:border-red-500 focus:ring-red-500":
- domainError,
- },
- )}
- placeholder="go.acme.com"
- value={domain}
- onChange={(e) => {
- setDomainError(null);
- setData({ ...data, [identifier]: e.target.value });
- }}
- onBlur={() => {
- if (
- domain.length > 0 &&
- domain.toLowerCase() !== originalDomain.toLowerCase()
- ) {
- fetch(`/api/domains/${domain}/exists`).then(async (res) => {
- const exists = await res.json();
- setDomainError(
- exists === 1 ? "Domain is already in use." : null,
- );
- });
- }
- }}
- aria-invalid="true"
- />
- )}
- {domainError ? (
- <div className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3">
- <AlertCircleFill
- className="h-5 w-5 text-red-500"
- aria-hidden="true"
- />
- </div>
- ) : domainType === "spare" ? (
- <div className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3">
- <CheckCircleFill
- className="h-5 w-5 text-green-500"
- aria-hidden="true"
- />
- </div>
- ) : null}
- </div>
- {domainError &&
- (domainError === "Domain is already in use." ? (
- <p className="mt-2 text-sm text-red-600" id="domain-error">
- Domain is already in use.{" "}
- <a
- className="underline"
- href="mailto:[email protected]?subject=My Domain Is Already In Use"
- >
- Contact us
- </a>{" "}
- if you'd like to use this domain for your workspace.
- </p>
- ) : (
- <p className="mt-2 text-sm text-red-600" id="domain-error">
- {domainError}
- </p>
- ))}
- {(domain.includes("/") || domainType === "website") && (
- <p className="mt-2 text-sm text-gray-500">
- Want to set up Dub.co to handle redirects on a subpath instead?{" "}
- <a
- href="https://dub.co/help/article/how-to-use-dub-with-subpath"
- target="_blank"
- className="underline"
- >
- Read this guide.
- </a>
- </p>
- )}
- </>
- );
-}
diff --git a/apps/web/ui/modals/add-edit-domain-modal.tsx b/apps/web/ui/modals/add-edit-domain-modal.tsx
index 349ef1dedc..1a33553740 100644
--- a/apps/web/ui/modals/add-edit-domain-modal.tsx
+++ b/apps/web/ui/modals/add-edit-domain-modal.tsx
@@ -2,16 +2,8 @@ import { clientAccessCheck } from "@/lib/api/tokens/permissions";
import useWorkspace from "@/lib/swr/use-workspace";
import { DomainProps } from "@/lib/types";
import { AddEditDomainForm } from "@/ui/domains/add-edit-domain-form";
-import {
- BlurImage,
- Button,
- ButtonProps,
- Logo,
- Modal,
- TooltipContent,
-} from "@dub/ui";
+import { Button, ButtonProps, Modal, TooltipContent } from "@dub/ui";
import { capitalize, pluralize } from "@dub/utils";
-import { useParams } from "next/navigation";
import {
Dispatch,
SetStateAction,
@@ -29,37 +21,25 @@ function AddEditDomainModal({
setShowAddEditDomainModal: Dispatch<SetStateAction<boolean>>;
props?: DomainProps;
}) {
- const { slug } = useParams() as { slug: string };
- const { logo } = useWorkspace();
-
return (
<Modal
- showModal={showAddEditDomainModal}
+ showModal={showAddEditDomainModal} // TODO change back to showAddEditDomainModal
setShowModal={setShowAddEditDomainModal}
- className="max-h-[95dvh]"
+ drawerRootProps={{ repositionInputs: false }}
+ className="max-w-lg"
>
- <div className="flex flex-col items-center justify-center gap-y-3 border-b border-gray-200 px-4 py-4 pt-8 sm:px-16">
- {logo ? (
- <BlurImage
- src={logo}
- alt={`Logo for ${slug}`}
- className="h-10 w-10 rounded-full border border-gray-200"
- width={20}
- height={20}
- />
- ) : (
- <Logo />
- )}
- <h1 className="text-lg font-medium">{props ? "Edit" : "Add"} Domain</h1>
+ <h3 className="border-b border-gray-200 px-4 py-4 text-lg font-medium sm:px-6">
+ {props ? "Edit" : "Add"} Domain
+ </h3>
+ <div className="bg-gray-50">
+ <AddEditDomainForm
+ props={props}
+ onSuccess={() => {
+ setShowAddEditDomainModal(false);
+ }}
+ className="p-8"
+ />
</div>
-
- <AddEditDomainForm
- props={props}
- onSuccess={() => {
- setShowAddEditDomainModal(false);
- }}
- className="bg-gray-50 px-4 py-8 sm:px-16"
- />
</Modal>
);
}
diff --git a/packages/ui/package.json b/packages/ui/package.json
index 4ce3f62252..5baaa2799a 100644
--- a/packages/ui/package.json
+++ b/packages/ui/package.json
@@ -52,6 +52,12 @@
"@react-aria/datepicker": "^3.10.0",
"@react-stately/datepicker": "^3.9.3",
"@tanstack/react-table": "^8.17.3",
+ "@visx/curve": "^3.3.0",
+ "@visx/gradient": "^3.3.0",
+ "@visx/group": "^3.3.0",
+ "@visx/responsive": "^2.10.0",
+ "@visx/scale": "^3.3.0",
+ "@visx/shape": "^2.12.2",
"class-variance-authority": "^0.7.0",
"cmdk": "^0.2.0",
"date-fns": "^3.6.0",
@@ -62,18 +68,12 @@
"js-sha256": "^0.11.0",
"linkify-react": "^4.1.3",
"linkifyjs": "^4.1.3",
- "lucide-react": "^0.367.0",
+ "lucide-react": "^0.462.0",
"react-day-picker": "^8.10.1",
"sonner": "^1.4.41",
"swr": "^2.1.5",
"use-debounce": "^8.0.4",
- "vaul": "^0.9.6",
- "@visx/curve": "^3.3.0",
- "@visx/gradient": "^3.3.0",
- "@visx/group": "^3.3.0",
- "@visx/responsive": "^2.10.0",
- "@visx/scale": "^3.3.0",
- "@visx/shape": "^2.12.2"
+ "vaul": "^0.9.6"
},
"author": "Steven Tey <[email protected]>",
"homepage": "https://dub.co",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index a5d6680846..c011971470 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -226,8 +226,8 @@ importers:
specifier: ^3.10.1
version: 3.10.1
lucide-react:
- specifier: ^0.367.0
- version: 0.367.0([email protected])
+ specifier: ^0.462.0
+ version: 0.462.0([email protected])
nanoid:
specifier: ^5.0.1
version: 5.0.1
@@ -506,7 +506,7 @@ importers:
version: link:../../tsconfig
tsup:
specifier: ^6.1.3
typescript:
specifier: ^5.1.6
version: 5.6.2
@@ -684,8 +684,8 @@ importers:
specifier: ^4.1.3
version: 4.1.3
lucide-react:
- specifier: ^0.367.0
- version: 0.367.0([email protected])
+ specifier: ^0.462.0
+ version: 0.462.0([email protected])
react-day-picker:
specifier: ^8.10.1
@@ -792,7 +792,7 @@ importers:
version: link:../tsconfig
tsup:
specifier: ^6.1.3
+ version: 6.1.3([email protected])
typescript:
specifier: ^5.1.6
version: 5.1.6
@@ -16072,10 +16072,10 @@ packages:
engines: {node: '>=16.14'}
dev: false
- resolution: {integrity: sha512-3FWiBaJiqMrx5a1sjH3CVdPqWnw/Z/PTVeeTDmOeILSs+8Ah+VhCd4FQMeHo6Z0WxHcm9piIOtilQwvceiCCKQ==}
+ resolution: {integrity: sha512-NTL7EbAao9IFtuSivSZgrAh4fZd09Lr+6MTkqIxuHaH2nnYiYIzXPo06cOxHg9wKLdj6LL8TByG4qpePqwgx/g==}
peerDependencies:
- react: ^16.5.1 || ^17.0.0 || ^18.0.0
+ react: ^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0-rc
dependencies:
react: 18.2.0
dev: false
@@ -20948,6 +20948,42 @@ packages:
- ts-node
dev: true
+ resolution: {integrity: sha512-eRpBnbfpDFng+EJNTQ90N7QAf4HAGGC7O3buHIjroKWK7D1ibk9/YnR/3cS8HsMU5T+6Oi+cnF+yU5WmCnB//Q==}
+ engines: {node: '>=14'}
+ hasBin: true
+ peerDependencies:
+ '@swc/core': ^1
+ postcss: ^8.4.12
+ typescript: ^4.1.0
+ peerDependenciesMeta:
+ '@swc/core':
+ optional: true
+ postcss:
+ optional: true
+ typescript:
+ optional: true
+ dependencies:
+ bundle-require: 3.1.2([email protected])
+ cac: 6.7.14
+ chokidar: 3.5.3
+ debug: 4.3.4
+ esbuild: 0.14.54
+ execa: 5.1.1
+ globby: 11.1.0
+ joycon: 3.1.1
+ postcss-load-config: 3.1.4([email protected])
+ resolve-from: 5.0.0
+ rollup: 2.79.1
+ source-map: 0.8.0-beta.0
+ sucrase: 3.34.0
+ tree-kill: 1.2.2
+ typescript: 5.1.6
+ transitivePeerDependencies:
+ - supports-color
+ - ts-node
+ dev: true
+
resolution: {integrity: sha512-L3o8hGkaHnu5TdJns+mCqFsDBo83bJ44rlK7e6VdanIvpea4ArPcU3swWGsLVbXak1PqQx/V+SSmFPujBK+zEQ==}
engines: {node: '>=14.18'}