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.

edit link & domain card

Steven Tey0fd9e619b963
diff --git a/apps/web/ui/domains/domain-card.tsx b/apps/web/ui/domains/domain-card.tsx
index ffea7900c7..72f31c437d 100644
--- a/apps/web/ui/domains/domain-card.tsx
+++ b/apps/web/ui/domains/domain-card.tsx
@@ -155,24 +155,22 @@ export default function DomainCard({ props }: { props: DomainProps }) {
<ExternalLink className="h-5 w-5" />
</a>
- {linkProps && (
- <NumberTooltip value={totalEvents?.clicks}>
- <Link
- href={`/${slug}/analytics?domain=${domain}&key=_root`}
- className="flex items-center space-x-1 rounded-md bg-gray-100 px-2 py-0.5 transition-all duration-75 hover:scale-105 active:scale-100"
- >
- <Chart className="h-4 w-4" />
- <p className="text-sm">
- {!totalEvents ? (
- <LoadingDots />
- ) : (
- nFormatter(totalEvents?.clicks)
- )}
- <span className="ml-1 hidden sm:inline-block">clicks</span>
- </p>
- </Link>
- </NumberTooltip>
- )}
+ <NumberTooltip value={totalEvents?.clicks}>
+ <Link
+ href={`/${slug}/analytics?domain=${domain}&key=_root`}
+ className="flex items-center space-x-1 rounded-md bg-gray-100 px-2 py-0.5 transition-all duration-75 hover:scale-105 active:scale-100"
+ >
+ <Chart className="h-4 w-4" />
+ <p className="text-sm">
+ {!totalEvents ? (
+ <LoadingDots />
+ ) : (
+ nFormatter(totalEvents?.clicks)
+ )}
+ <span className="ml-1 hidden sm:inline-block">clicks</span>
+ </p>
+ </Link>
+ </NumberTooltip>
{primary && (
<span className="rounded-full bg-blue-500 px-3 py-0.5 text-xs text-white">
diff --git a/apps/web/ui/links/link-card.tsx b/apps/web/ui/links/link-card.tsx
index acd4202cff..76b0762f25 100644
--- a/apps/web/ui/links/link-card.tsx
+++ b/apps/web/ui/links/link-card.tsx
@@ -32,6 +32,7 @@ import {
isDubDomain,
linkConstructor,
nFormatter,
+ nanoid,
punycode,
timeAgo,
} from "@dub/utils";
@@ -158,7 +159,7 @@ export default function LinkCard({
// @ts-expect-error
duplicateProps: {
...propsToDuplicate,
- key: `${punycode(key)}-copy`,
+ key: key === "_root" ? nanoid(7) : `${punycode(key)}-copy`,
clicks: 0,
},
});
@@ -460,14 +461,18 @@ export default function LinkCard({
<Lock className="xs:block hidden h-4 w-4 text-gray-500" />
</Tooltip>
)}
- <a
- href={url}
- target="_blank"
- rel="noopener noreferrer"
- className="xs:block hidden max-w-[140px] truncate text-sm font-medium text-gray-700 underline-offset-2 hover:underline sm:max-w-[300px] md:max-w-[360px] xl:max-w-[420px]"
- >
- {url}
- </a>
+ {url ? (
+ <a
+ href={url}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="xs:block hidden max-w-[140px] truncate text-sm font-medium text-gray-700 underline-offset-2 hover:underline sm:max-w-[300px] md:max-w-[360px] xl:max-w-[420px]"
+ >
+ {url}
+ </a>
+ ) : (
+ <p className="text-sm text-gray-400">No URL configured</p>
+ )}
</div>
</div>
</div>