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 ProgramCard and ProgramInviteCard

Steven Tey76f9f4583a5f
diff --git a/apps/web/app/partners.dub.co/(dashboard)/[partnerId]/page-client.tsx b/apps/web/app/partners.dub.co/(dashboard)/[partnerId]/page-client.tsx
index 1188190026..206bb2aa09 100644
--- a/apps/web/app/partners.dub.co/(dashboard)/[partnerId]/page-client.tsx
+++ b/apps/web/app/partners.dub.co/(dashboard)/[partnerId]/page-client.tsx
@@ -15,7 +15,7 @@ export function PartnersDashboardPageClient() {
partnerId?: string;
};
- const { data: programs, error } = useSWR<ProgramProps[]>(
+ const { data: programs, isLoading } = useSWR<ProgramProps[]>(
`/api/partners/${partnerId}/programs`,
fetcher,
{
@@ -33,32 +33,7 @@ export function PartnersDashboardPageClient() {
return (
<MaxWidthWrapper>
- {invites && invites.length > 0 && (
- <div className="mb-8 grid gap-4">
- {invites.map((invite) => (
- <ProgramInviteCard key={invite.id} invite={invite} />
- ))}
- </div>
- )}
- {programs === undefined ? (
- error ? (
- <div className="mt-8 text-center text-sm text-neutral-500">
- Failed to load programs
- </div>
- ) : (
- <div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
- {Array.from({ length: 3 }).map((_, idx) => (
- <ProgramCardSkeleton key={idx} />
- ))}
- </div>
- )
- ) : programs.length > 0 ? (
- <div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
- {programs.map((program) => (
- <ProgramCard key={program.id} program={program} />
- ))}
- </div>
- ) : (
+ {programs?.length == 0 && invites?.length == 0 ? (
<AnimatedEmptyState
title="No programs found"
description="Enroll in programs to start earning."
@@ -73,6 +48,23 @@ export function PartnersDashboardPageClient() {
}
learnMoreHref="https://dub.co/help/article/dub-conversions"
/>
+ ) : (
+ <div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
+ {isLoading ? (
+ Array.from({ length: 3 }).map((_, idx) => (
+ <ProgramCardSkeleton key={idx} />
+ ))
+ ) : (
+ <>
+ {invites?.map((invite) => (
+ <ProgramInviteCard key={invite.id} invite={invite} />
+ ))}
+ {programs?.map((program) => (
+ <ProgramCard key={program.id} program={program} />
+ ))}
+ </>
+ )}
+ </div>
)}
</MaxWidthWrapper>
);
diff --git a/apps/web/ui/partners/program-card.tsx b/apps/web/ui/partners/program-card.tsx
index 13944f7b65..4ebb6d9b3a 100644
--- a/apps/web/ui/partners/program-card.tsx
+++ b/apps/web/ui/partners/program-card.tsx
@@ -1,8 +1,8 @@
import usePartnerAnalytics from "@/lib/swr/use-partner-analytics";
import { ProgramProps } from "@/lib/types";
import { MiniAreaChart } from "@dub/blocks";
-import { BlurImage } from "@dub/ui";
-import { currencyFormatter, DICEBEAR_AVATAR_URL, nFormatter } from "@dub/utils";
+import { BlurImage, StatusBadge } from "@dub/ui";
+import { currencyFormatter, DICEBEAR_AVATAR_URL } from "@dub/utils";
import Link from "next/link";
import { useParams } from "next/navigation";
import { useMemo } from "react";
@@ -49,13 +49,13 @@ export function ProgramCard({ program }: { program: ProgramProps }) {
<span className="text-base font-medium text-neutral-900">
{program.name}
</span>
- {analytics ? (
- <span className="text-sm leading-none text-neutral-600">
- {nFormatter(analytics?.sales)} sales
- </span>
- ) : (
- <div className="h-3.5 w-20 animate-pulse rounded-md bg-neutral-200" />
- )}
+ <StatusBadge
+ variant="success"
+ icon={null}
+ className="rounded-full py-0.5"
+ >
+ Enrolled
+ </StatusBadge>
</div>
</div>
<div className="mt-6 grid grid-cols-[min-content,minmax(0,1fr)] gap-4 rounded-md border border-neutral-100 bg-neutral-50 p-5">
diff --git a/apps/web/ui/partners/program-invite-card.tsx b/apps/web/ui/partners/program-invite-card.tsx
index b2a85ccbb2..a2a0bd9f56 100644
--- a/apps/web/ui/partners/program-invite-card.tsx
+++ b/apps/web/ui/partners/program-invite-card.tsx
@@ -1,7 +1,7 @@
import { acceptProgramInviteAction } from "@/lib/actions/partners/accept-program-invite";
import { ProgramInviteProps } from "@/lib/types";
import { ProgramCommissionDescription } from "@/ui/partners/program-commission-description";
-import { BlurImage, Button } from "@dub/ui";
+import { BlurImage, Button, StatusBadge } from "@dub/ui";
import { DICEBEAR_AVATAR_URL } from "@dub/utils";
import { useAction } from "next-safe-action/hooks";
import { useParams } from "next/navigation";
@@ -28,8 +28,15 @@ export function ProgramInviteCard({ invite }: { invite: ProgramInviteProps }) {
});
return (
- <div className="flex items-center justify-between rounded-md border border-neutral-300 bg-white p-4">
- <div className="flex items-center gap-4">
+ <div className="hover:drop-shadow-card-hover relative flex flex-col items-center justify-center gap-2 rounded-md border border-neutral-300 bg-neutral-50 p-4 transition-[filter]">
+ <StatusBadge
+ variant="new"
+ icon={null}
+ className="absolute left-4 top-4 rounded-full py-0.5"
+ >
+ Invited
+ </StatusBadge>
+ <div className="flex size-10 items-center justify-center rounded-full border border-neutral-200 bg-white">
<BlurImage
width={96}
height={96}
@@ -40,18 +47,20 @@ export function ProgramInviteCard({ invite }: { invite: ProgramInviteProps }) {
alt={invite.program.name}
className="size-6 rounded-full"
/>
- <div className="flex flex-col gap-0.5">
- <span className="text-base font-medium text-neutral-900">
- {invite.program.name}
- </span>
- <span className="text-sm text-neutral-600">
- <ProgramCommissionDescription program={invite.program} />
- </span>
- </div>
</div>
+ <p className="text-base font-medium text-neutral-900">
+ {invite.program.name}
+ </p>
+ <p className="text-balance text-center text-xs text-neutral-600">
+ <ProgramCommissionDescription
+ program={invite.program}
+ amountClassName="font-light"
+ periodClassName="font-light"
+ />
+ </p>
<Button
text="Accept invite"
- className="h-9 w-fit"
+ className="h-8"
loading={isExecuting}
onClick={() =>
executeAsync({