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.

UI fixes/improvements

Tim Wilson05dde31c12a0
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/links/add-edit-additional-partner-link-modal.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/links/add-edit-additional-partner-link-modal.tsx
index aa860e387d..6861549154 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/links/add-edit-additional-partner-link-modal.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/links/add-edit-additional-partner-link-modal.tsx
@@ -123,10 +123,12 @@ function AddDestinationUrlModalContent({
const isEditing = !!link;
return (
- <form onSubmit={(e) => {
- e.stopPropagation();
- handleSubmit(onSubmit)(e);
- }}>
+ <form
+ onSubmit={(e) => {
+ e.stopPropagation();
+ handleSubmit(onSubmit)(e);
+ }}
+ >
<div className="sticky top-0 z-10 border-b border-neutral-200 bg-white">
<div className="flex h-16 items-center justify-between px-6 py-4">
<h2 className="text-lg font-semibold">
@@ -199,6 +201,7 @@ function AddDestinationUrlModalContent({
<div className="flex items-start gap-2.5">
<input
type="checkbox"
+ id="conversionTracking"
className="mt-1 h-4 w-4 rounded border-neutral-300 text-neutral-900 focus:ring-neutral-500"
required
/>
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/links/group-additional-links.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/links/group-additional-links.tsx
index 2ba86a66ee..489372b0b1 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/links/group-additional-links.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/links/group-additional-links.tsx
@@ -3,7 +3,7 @@
import { mutatePrefix } from "@/lib/swr/mutate";
import { useApiMutation } from "@/lib/swr/use-api-mutation";
import useGroup from "@/lib/swr/use-group";
-import { AdditionalPartnerLink } from "@/lib/types";
+import { AdditionalPartnerLink, GroupProps } from "@/lib/types";
import {
MAX_ADDITIONAL_PARTNER_LINKS,
updateGroupSchema,
@@ -13,19 +13,44 @@ import { ThreeDots } from "@/ui/shared/icons";
import { Button, LinkLogo, NumberStepper, Popover, Switch } from "@dub/ui";
import { Trash } from "@dub/ui/icons";
import { cn, getApexDomain, getPrettyUrl } from "@dub/utils";
-import { PropsWithChildren, useEffect, useState } from "react";
+import { PropsWithChildren, useState } from "react";
import { useForm } from "react-hook-form";
import { toast } from "sonner";
import { z } from "zod";
import { useAddDestinationUrlModal } from "./add-edit-additional-partner-link-modal";
+export function GroupAdditionalLinks() {
+ const { group, loading } = useGroup();
+
+ return (
+ <div className="flex flex-col divide-y divide-neutral-200 rounded-lg border border-neutral-200">
+ <div className="px-6 py-6">
+ <h3 className="text-content-emphasis text-lg font-semibold leading-7">
+ Additional partner links
+ </h3>
+ <p className="text-content-subtle text-sm font-normal leading-5">
+ Allow and configure extra partner links
+ </p>
+ </div>
+ {group ? (
+ <GroupAdditionalLinksForm group={group} />
+ ) : loading ? (
+ <div className="flex h-[4.5rem] animate-pulse rounded-b-lg border-t border-neutral-200 bg-neutral-100" />
+ ) : (
+ <div className="text-content-subtle h-20 text-center">
+ Failed to load additional partner links settings
+ </div>
+ )}
+ </div>
+ );
+}
+
type FormData = Pick<
z.input<typeof updateGroupSchema>,
"maxPartnerLinks" | "additionalLinks"
>;
-export function GroupAdditionalLinks() {
- const { group } = useGroup();
+export function GroupAdditionalLinksForm({ group }: { group: GroupProps }) {
const { makeRequest: updateGroup, isSubmitting } = useApiMutation();
const { addDestinationUrlModal, setIsOpen } = useAddDestinationUrlModal({});
const [enableAdditionalLinks, setEnableAdditionalLinks] = useState(false);
@@ -34,28 +59,15 @@ export function GroupAdditionalLinks() {
handleSubmit,
watch,
setValue,
- reset,
formState: { isDirty, isValid },
} = useForm<FormData>({
mode: "onBlur",
defaultValues: {
- maxPartnerLinks: group?.maxPartnerLinks,
- additionalLinks: group?.additionalLinks || [],
+ maxPartnerLinks: group.maxPartnerLinks,
+ additionalLinks: group.additionalLinks || [],
},
});
- // Reset form values when group data becomes available
- useEffect(() => {
- if (group) {
- setEnableAdditionalLinks(group.maxPartnerLinks !== 0);
-
- reset({
- maxPartnerLinks: group.maxPartnerLinks,
- additionalLinks: group.additionalLinks || [],
- });
- }
- }, [group, reset]);
-
const onSubmit = async (data: FormData) => {
if (!group) return;
@@ -73,102 +85,99 @@ export function GroupAdditionalLinks() {
const maxPartnerLinks = watch("maxPartnerLinks") || 0;
return (
- <form onSubmit={handleSubmit(onSubmit)}>
- <div className="flex min-h-80 flex-col divide-y divide-neutral-200 rounded-lg border border-neutral-200">
- <div className="px-6 py-6">
- <h3 className="text-content-emphasis text-lg font-semibold leading-7">
- Additional partner links
- </h3>
- <p className="text-content-subtle text-sm font-normal leading-5">
- Allow and configure extra partner links
- </p>
- </div>
+ <form
+ onSubmit={handleSubmit(onSubmit)}
+ className="flex flex-col divide-y divide-neutral-200"
+ >
+ {enableAdditionalLinks && (
+ <>
+ <SettingsRow
+ heading="Link limit"
+ description="Set how many extra links a partner can create"
+ >
+ <NumberStepper
+ value={maxPartnerLinks}
+ onChange={(v) =>
+ setValue("maxPartnerLinks", v, {
+ shouldDirty: true,
+ shouldValidate: true,
+ })
+ }
+ min={1}
+ max={MAX_ADDITIONAL_PARTNER_LINKS}
+ step={1}
+ className="w-full"
+ />
+ </SettingsRow>
+
+ <SettingsRow
+ heading="Destinations URLs"
+ description="Add additional destination URLs the partner can select"
+ >
+ <div>
+ <div className="flex flex-col gap-2">
+ {additionalLinks.length > 0 ? (
+ additionalLinks.map((link, index) => (
+ <DestinationUrl key={index} link={link} />
+ ))
+ ) : (
+ <div className="border-border-subtle text-content-subtle flex h-16 items-center gap-3 rounded-xl border bg-white p-4 text-sm">
+ No additional destination URLs
+ </div>
+ )}
+ </div>
- {enableAdditionalLinks && (
- <>
- <SettingsRow
- heading="Link limit"
- description="Set how many extra links a partner can create"
- >
- <NumberStepper
- value={maxPartnerLinks}
- onChange={(v) =>
- setValue("maxPartnerLinks", v, {
- shouldDirty: true,
- shouldValidate: true,
- })
+ <Button
+ text="Add destination URL"
+ variant="primary"
+ className="mt-4 h-8 w-fit rounded-lg px-3"
+ onClick={() => setIsOpen(true)}
+ disabled={
+ additionalLinks.length >= MAX_ADDITIONAL_PARTNER_LINKS
+ }
+ disabledTooltip={
+ additionalLinks.length >= MAX_ADDITIONAL_PARTNER_LINKS
+ ? `You can only create up to ${MAX_ADDITIONAL_PARTNER_LINKS} additional destination URLs.`
+ : undefined
}
- min={1}
- max={MAX_ADDITIONAL_PARTNER_LINKS}
- step={1}
- className="w-full"
/>
- </SettingsRow>
-
- <SettingsRow
- heading="Destinations URLs"
- description="Add additional destination URLs the partner can select"
- >
- <div>
- <div className="flex flex-col gap-2">
- {additionalLinks.length > 0 &&
- additionalLinks.map((link, index) => (
- <DestinationUrl key={index} link={link} />
- ))}
- </div>
+ </div>
+ </SettingsRow>
+ </>
+ )}
- <Button
- text="Add destination URL"
- variant="primary"
- className="mt-4 h-8 w-fit rounded-lg px-3"
- onClick={() => setIsOpen(true)}
- disabled={
- additionalLinks.length >= MAX_ADDITIONAL_PARTNER_LINKS
- }
- disabledTooltip={
- additionalLinks.length >= MAX_ADDITIONAL_PARTNER_LINKS
- ? `You can only create up to ${MAX_ADDITIONAL_PARTNER_LINKS} additional destination URLs.`
- : undefined
- }
- />
- </div>
- </SettingsRow>
- </>
- )}
+ <div className="flex items-center justify-between rounded-b-lg bg-neutral-50 px-6 py-5">
+ <div className="flex items-center gap-3">
+ <Switch
+ checked={enableAdditionalLinks}
+ fn={(checked: boolean) => {
+ setEnableAdditionalLinks(checked);
+ const newValue = checked ? MAX_ADDITIONAL_PARTNER_LINKS : 0;
- <div className="flex items-center justify-between rounded-b-lg border-t border-neutral-200 bg-neutral-50 px-6 py-5">
- <div className="flex items-center gap-3">
- <Switch
- checked={enableAdditionalLinks}
- fn={(checked: boolean) => {
- setEnableAdditionalLinks(checked);
- const newValue = checked ? MAX_ADDITIONAL_PARTNER_LINKS : 0;
+ setValue("maxPartnerLinks", newValue, {
+ shouldDirty: true,
+ shouldValidate: true,
+ });
- setValue("maxPartnerLinks", newValue, {
+ if (!checked) {
+ setValue("additionalLinks", [], {
shouldDirty: true,
shouldValidate: true,
});
-
- if (!checked) {
- setValue("additionalLinks", [], {
- shouldDirty: true,
- shouldValidate: true,
- });
- }
- }}
- />
- <span className="text-sm font-medium text-neutral-800">
- Enable additional partner links
- </span>
- </div>
- <div>
- <Button
- text="Save changes"
- className="h-8"
- loading={isSubmitting}
- disabled={!isValid || !isDirty}
- />
- </div>
+ }
+ }}
+ />
+ <span className="text-sm font-medium text-neutral-800">
+ Enable additional partner links
+ </span>
+ </div>
+ <div>
+ <Button
+ text="Save changes"
+ className="h-8"
+ loading={isSubmitting}
+ disabled={!isValid || !isDirty}
+ />
</div>
</div>
{addDestinationUrlModal}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/links/group-default-links.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/links/group-default-links.tsx
index 1ebdbb3898..a63582829d 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/links/group-default-links.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/links/group-default-links.tsx
@@ -16,13 +16,12 @@ import { useDefaultPartnerLinkSheet } from "./add-edit-default-partner-link-shee
import { PartnerLinkPreview } from "./partner-link-preview";
export function GroupDefaultLinks() {
- const { group } = useGroup();
+ const { group, loading } = useGroup();
- const defaultLinks = group?.defaultLinks || [];
- const hasReachedMaxLinks = defaultLinks.length >= MAX_DEFAULT_PARTNER_LINKS;
+ const defaultLinks = group?.defaultLinks;
return (
- <div className="flex min-h-80 flex-col gap-6 rounded-lg border border-neutral-200 p-6">
+ <div className="flex flex-col gap-6 rounded-lg border border-neutral-200 p-6">
<div className="flex items-center justify-between">
<div>
<h3 className="text-content-emphasis text-lg font-semibold leading-7">
@@ -33,15 +32,25 @@ export function GroupDefaultLinks() {
</p>
</div>
- <CreateDefaultLinkButton hasReachedMaxLinks={hasReachedMaxLinks} />
+ {defaultLinks && (
+ <CreateDefaultLinkButton
+ hasReachedMaxLinks={
+ defaultLinks.length >= MAX_DEFAULT_PARTNER_LINKS
+ }
+ />
+ )}
</div>
- {defaultLinks.length > 0 ? (
+ {defaultLinks && defaultLinks.length > 0 ? (
<div className="flex flex-col gap-4">
{defaultLinks.map((link) => (
<DefaultLinkPreview key={link.id} link={link} />
))}
</div>
+ ) : loading ? (
+ <div className="flex flex-col gap-4">
+ <div className="h-[76px] animate-pulse rounded-xl bg-neutral-200" />
+ </div>
) : (
<NoDefaultLinks />
)}
@@ -171,13 +180,13 @@ function DefaultLinkPreview({ link }: { link: DefaultPartnerLink }) {
function NoDefaultLinks() {
return (
<div className="flex h-[200px] flex-col items-center justify-center gap-6 rounded-lg bg-neutral-50 p-4">
- <Hyperlink className="size-6 text-neutral-800" />
+ <Hyperlink className="text-content-emphasis size-6" />
<div className="flex flex-col gap-1 text-center">
- <h2 className="text-base font-medium text-neutral-900">
- Default partner links
+ <h2 className="text-content-emphasis text-base font-medium">
+ Default links
</h2>
- <p className="text-sm font-normal text-neutral-600">
- No default partner links have been created yet.
+ <p className="text-content-subtle text-sm">
+ No default links have been created yet
</p>
</div>
</div>
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/links/group-utm.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/links/group-utm.tsx
index d98162c15c..bc9319bc27 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/links/group-utm.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/links/group-utm.tsx
@@ -5,8 +5,9 @@ import { useApiMutation } from "@/lib/swr/use-api-mutation";
import useGroup from "@/lib/swr/use-group";
import useWorkspace from "@/lib/swr/use-workspace";
import { UTMTemplateSchema } from "@/lib/zod/schemas/utm";
+import { useConfirmModal } from "@/ui/modals/confirm-modal";
import { Button, UTMBuilder } from "@dub/ui";
-import { PropsWithChildren, useEffect, useState } from "react";
+import { PropsWithChildren, useEffect, useRef, useState } from "react";
import { useForm } from "react-hook-form";
import { toast } from "sonner";
import { z } from "zod";
@@ -18,10 +19,23 @@ type FormData = {
export function GroupUTM() {
const { id: workspaceId } = useWorkspace();
const { group, loading: isLoadingGroup } = useGroup();
+
+ const formRef = useRef<HTMLFormElement>(null);
+
const { makeRequest: updateGroup, isSubmitting: isUpdatingGroup } =
useApiMutation();
const [isUpdatingTemplate, setIsUpdatingTemplate] = useState(false);
+ const { confirmModal, setShowConfirmModal } = useConfirmModal({
+ title: "Save updated UTM parameters",
+ description:
+ "All existing and new partner links will automatically be updated with these UTM parameters.",
+ confirmText: "Save",
+ onConfirm: async () => {
+ formRef.current?.requestSubmit();
+ },
+ });
+
const { handleSubmit, watch, setValue, reset } = useForm<FormData>({
mode: "onBlur",
defaultValues: {
@@ -126,7 +140,8 @@ export function GroupUTM() {
const currentValues = watch();
return (
- <form onSubmit={handleSubmit(onSubmit)}>
+ <form ref={formRef} onSubmit={handleSubmit(onSubmit)}>
+ {confirmModal}
<div className="flex min-h-80 flex-col divide-y divide-neutral-200 rounded-lg border border-neutral-200">
<SettingsRow
heading="UTM Parameters"
@@ -153,6 +168,7 @@ export function GroupUTM() {
className="h-8 w-fit"
loading={isUpdatingGroup || isUpdatingTemplate}
disabled={isLoadingGroup}
+ onClick={() => setShowConfirmModal(true)}
/>
</div>
</div>
diff --git a/apps/web/ui/domains/domain-selector.tsx b/apps/web/ui/domains/domain-selector.tsx
index 59191029f2..9321178881 100644
--- a/apps/web/ui/domains/domain-selector.tsx
+++ b/apps/web/ui/domains/domain-selector.tsx
@@ -73,7 +73,7 @@ export function DomainSelector({
<Combobox
options={loading ? undefined : domainOptions}
setSelected={(option) => {
- setSelectedDomain(option.value);
+ setSelectedDomain(option?.value || "");
}}
selected={selectedOption}
icon={loading ? null : selectedOption?.icon}