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.

hide UTM settings when query link structure is selected

Pedro Ladeira4d94a7dc2ed1
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/links/group-link-settings.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/links/group-link-settings.tsx
index 9195aca77c..e7b10629a5 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/links/group-link-settings.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/links/group-link-settings.tsx
@@ -12,6 +12,8 @@ import { GroupSettingsRow } from "@/ui/partners/groups/group-settings-row";
import { Badge, Button, UTMBuilder } from "@dub/ui";
import { CircleCheck } from "@dub/ui/icons";
import { cn, deepEqual } from "@dub/utils";
+import { PartnerLinkStructure } from "@prisma/client";
+import { AnimatePresence, motion } from "motion/react";
import { useState } from "react";
import { useForm } from "react-hook-form";
import { toast } from "sonner";
@@ -92,6 +94,8 @@ function GroupLinkSettingsForm({ group }: { group: GroupProps }) {
});
const currentValues = watch();
+ const showUtmSection =
+ currentValues.linkStructure !== PartnerLinkStructure.query;
const onSubmit = async (data: FormData) => {
if (!group || !workspaceId) return;
@@ -204,7 +208,7 @@ function GroupLinkSettingsForm({ group }: { group: GroupProps }) {
key={type.id}
className={cn(
"relative flex w-full cursor-pointer items-start gap-0.5 rounded-md border border-neutral-200 bg-white p-3 text-neutral-600",
- "transition-all duration-150 hover:bg-neutral-50",
+ "transition-[border-color,background-color,color,box-shadow] duration-150 ease-out hover:bg-neutral-50",
isSelected &&
"border-black bg-neutral-50 text-neutral-900 ring-1 ring-black",
)}
@@ -239,24 +243,40 @@ function GroupLinkSettingsForm({ group }: { group: GroupProps }) {
</div>
</GroupSettingsRow>
- <GroupSettingsRow
- heading="UTM parameters"
- description="Configure [UTM tracking parameters](https://dub.co/help/article/partner-link-settings#utm-parameters) for all links in this group"
- >
- <UTMBuilder
- values={{
- utm_source: currentValues.utm_source || "",
- utm_medium: currentValues.utm_medium || "",
- utm_campaign: currentValues.utm_campaign || "",
- utm_term: currentValues.utm_term || "",
- utm_content: currentValues.utm_content || "",
- ref: currentValues.ref || "",
- }}
- onChange={(key, value) => {
- setValue(key, value, { shouldDirty: true });
- }}
- />
- </GroupSettingsRow>
+ <AnimatePresence initial={false}>
+ {showUtmSection && (
+ <motion.div
+ key="utm-parameters"
+ initial={{ opacity: 0, height: 0 }}
+ animate={{ opacity: 1, height: "auto" }}
+ exit={{ opacity: 0, height: 0 }}
+ transition={{
+ height: { duration: 0.2, ease: [0.23, 1, 0.32, 1] },
+ opacity: { duration: 0.15, ease: [0.23, 1, 0.32, 1] },
+ }}
+ className="overflow-hidden"
+ >
+ <GroupSettingsRow
+ heading="UTM parameters"
+ description="Configure [UTM tracking parameters](https://dub.co/help/article/partner-link-settings#utm-parameters) for all links in this group"
+ >
+ <UTMBuilder
+ values={{
+ utm_source: currentValues.utm_source || "",
+ utm_medium: currentValues.utm_medium || "",
+ utm_campaign: currentValues.utm_campaign || "",
+ utm_term: currentValues.utm_term || "",
+ utm_content: currentValues.utm_content || "",
+ ref: currentValues.ref || "",
+ }}
+ onChange={(key, value) => {
+ setValue(key, value, { shouldDirty: true });
+ }}
+ />
+ </GroupSettingsRow>
+ </motion.div>
+ )}
+ </AnimatePresence>
<div className="flex items-center justify-end rounded-b-lg border-t border-neutral-200 bg-neutral-50 px-6 py-5">
<Button