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.

finalize UI + address CR feedback

Steven Tey1fd451980eee
diff --git a/apps/web/app/(ee)/api/cron/partner-platforms/website/get-domain-rating.ts b/apps/web/app/(ee)/api/cron/partner-platforms/website/get-domain-rating.ts
index eac63a79ca..0ed5050450 100644
--- a/apps/web/app/(ee)/api/cron/partner-platforms/website/get-domain-rating.ts
+++ b/apps/web/app/(ee)/api/cron/partner-platforms/website/get-domain-rating.ts
@@ -1,3 +1,4 @@
+import { fetchWithTimeout } from "@dub/utils";
import * as z from "zod/v4";
const domainRatingSchema = z.object({
@@ -7,7 +8,7 @@ const domainRatingSchema = z.object({
});
export async function getDomainRating(target: string) {
- const response = await fetch(
+ const response = await fetchWithTimeout(
`https://api.ahrefs.com/v3/public/domain-rating-free?target=${encodeURIComponent(target)}&output=json`,
{
headers: {
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/network/network-partner-card.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/network/network-partner-card.tsx
index 8302f3db8b..7df753d61e 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/network/network-partner-card.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/network/network-partner-card.tsx
@@ -86,10 +86,10 @@ export function NetworkPartnerCard({
label: field.label,
icon: field.icon,
...field.data(partner.platforms),
- })).sort((a, b) => {
- if (a.verified === b.verified) return 0;
- return a.verified ? -1 : 1;
- })
+ })).sort(
+ (a, b) =>
+ getPlatformSortOrder(a) - getPlatformSortOrder(b),
+ )
: null,
[partner],
);
@@ -240,6 +240,18 @@ export function NetworkPartnerCard({
);
}
+function getPlatformSortOrder({
+ verified,
+ value,
+}: {
+ verified: boolean;
+ value?: string | null;
+}) {
+ if (verified) return 0;
+ if (value) return 1;
+ return 2;
+}
+
function NetworkPartnerCardActions({
partner,
onToggleStarred,
@@ -339,10 +351,7 @@ function PlatformStatCard({
>
<div className="relative">
<PlatformIcon
- className={cn(
- "size-3.5",
- !verified && "text-content-subtle opacity-40",
- )}
+ className={cn("size-3.5", !value && "text-content-subtle opacity-40")}
/>
{verified && (
<BadgeCheck2Fill className="absolute -right-1.5 -top-1.5 size-3 text-green-600" />
@@ -364,19 +373,21 @@ function PlatformStatCard({
return (
<DynamicTooltipWrapper
- tooltipProps={{
- content: (
- <PlatformStatTooltipContent
- label={label}
- icon={PlatformIcon}
- value={value}
- stat={stat}
- info={info}
- verified={verified}
- verifiedAt={verifiedAt}
- />
- ),
- }}
+ tooltipProps={
+ value
+ ? {
+ content: (
+ <PlatformStatTooltipContent
+ icon={PlatformIcon}
+ value={value}
+ stat={stat}
+ info={info}
+ verifiedAt={verifiedAt}
+ />
+ ),
+ }
+ : undefined
+ }
>
<As
{...(href
@@ -395,36 +406,21 @@ function PlatformStatCard({
}
function PlatformStatTooltipContent({
- label,
icon: PlatformIcon,
value,
stat,
info,
- verified,
verifiedAt,
}: {
- label: string;
icon: Icon;
value?: string | null;
stat?: string | null;
info?: string[];
- verified: boolean;
verifiedAt?: Date | null;
}) {
- if (!verified || !value) {
- return (
- <div className="flex items-center gap-2 p-2.5 text-xs">
- <div className="border-border-subtle flex size-7 shrink-0 items-center justify-center rounded-full border">
- <PlatformIcon className="text-content-subtle size-3.5 opacity-40" />
- </div>
- <span className="text-content-subtle font-medium">Not connected</span>
- </div>
- );
- }
-
return (
- <div className="flex flex-col gap-2 p-2.5 text-xs">
- <div className="flex items-center gap-2">
+ <div className="flex flex-col gap-2 text-xs">
+ <div className="flex items-center gap-2 p-3 pb-1.5">
<div className="border-border-subtle flex size-7 shrink-0 items-center justify-center rounded-full border">
<PlatformIcon className="size-3.5" />
</div>
@@ -439,12 +435,16 @@ function PlatformStatTooltipContent({
)}
</div>
</div>
- {verifiedAt && (
- <div className="text-content-subtle flex items-center gap-1.5 font-medium">
- <BadgeCheck2Fill className="size-3 shrink-0 text-green-600" />
- Verified {timeAgo(verifiedAt, { withAgo: true })}
- </div>
- )}
+ <div className="text-content-subtle border-border-subtle flex items-center gap-1.5 border-t px-3 py-1.5 font-medium">
+ {verifiedAt ? (
+ <>
+ <BadgeCheck2Fill className="size-3 shrink-0 text-green-600" />
+ Verified {timeAgo(verifiedAt, { withAgo: true })}
+ </>
+ ) : (
+ "Not verified"
+ )}
+ </div>
</div>
);
}
diff --git a/apps/web/lib/partners/partner-platforms.ts b/apps/web/lib/partners/partner-platforms.ts
index 153a6e2e78..c72d6e4d26 100644
--- a/apps/web/lib/partners/partner-platforms.ts
+++ b/apps/web/lib/partners/partner-platforms.ts
@@ -7,7 +7,12 @@ import {
Twitter,
YouTube,
} from "@dub/ui/icons";
-import { getPrettyUrl, getUrlFromStringIfValid, nFormatter } from "@dub/utils";
+import {
+ getPrettyUrl,
+ getUrlFromStringIfValid,
+ nFormatter,
+ pluralize,
+} from "@dub/utils";
import { PartnerPlatformProps } from "../types";
export const PARTNER_PLATFORM_FIELDS: {
@@ -62,10 +67,10 @@ export const PARTNER_PLATFORM_FIELDS: {
: null,
info: [
youtube?.subscribers && youtube?.verifiedAt
- ? `${nFormatter(Number(youtube.subscribers))} subscribers`
+ ? `${nFormatter(Number(youtube.subscribers))} ${pluralize("subscriber", Number(youtube.subscribers))}`
: null,
youtube?.views && youtube?.verifiedAt
- ? `${nFormatter(Number(youtube.views))} views`
+ ? `${nFormatter(Number(youtube.views))} ${pluralize("view", Number(youtube.views))}`
: null,
].filter(Boolean),
stat:
@@ -90,10 +95,10 @@ export const PARTNER_PLATFORM_FIELDS: {
: null,
info: [
twitter?.subscribers && twitter?.verifiedAt
- ? `${nFormatter(Number(twitter.subscribers))} followers`
+ ? `${nFormatter(Number(twitter.subscribers))} ${pluralize("follower", Number(twitter.subscribers))}`
: null,
twitter?.posts && twitter?.verifiedAt
- ? `${nFormatter(Number(twitter.posts))} tweets`
+ ? `${nFormatter(Number(twitter.posts))} ${pluralize("tweet", Number(twitter.posts))}`
: null,
].filter(Boolean),
stat:
@@ -134,10 +139,10 @@ export const PARTNER_PLATFORM_FIELDS: {
: null,
info: [
instagram?.subscribers && instagram?.verifiedAt
- ? `${nFormatter(Number(instagram.subscribers))} followers`
+ ? `${nFormatter(Number(instagram.subscribers))} ${pluralize("follower", Number(instagram.subscribers))}`
: null,
instagram?.posts && instagram?.verifiedAt
- ? `${nFormatter(Number(instagram.posts))} posts`
+ ? `${nFormatter(Number(instagram.posts))} ${pluralize("post", Number(instagram.posts))}`
: null,
].filter(Boolean),
stat:
@@ -162,10 +167,10 @@ export const PARTNER_PLATFORM_FIELDS: {
: null,
info: [
tiktok?.subscribers && tiktok?.verifiedAt
- ? `${nFormatter(Number(tiktok.subscribers))} followers`
+ ? `${nFormatter(Number(tiktok.subscribers))} ${pluralize("follower", Number(tiktok.subscribers))}`
: null,
tiktok?.posts && tiktok?.verifiedAt
- ? `${nFormatter(Number(tiktok.posts))} posts`
+ ? `${nFormatter(Number(tiktok.posts))} ${pluralize("post", Number(tiktok.posts))} `
: null,
].filter(Boolean),
stat: