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.

improve PartnerBountyCard

Steven Tey8bf33a26dcb7
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/bounties/partner-bounty-card.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/bounties/partner-bounty-card.tsx
index 8eef437c1c..b73f42f347 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/bounties/partner-bounty-card.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/bounties/partner-bounty-card.tsx
@@ -3,11 +3,13 @@ import { PartnerBountyProps } from "@/lib/types";
import { BountyPerformance } from "@/ui/partners/bounties/bounty-performance";
import { BountyThumbnailImage } from "@/ui/partners/bounties/bounty-thumbnail-image";
import { useClaimBountyModal } from "@/ui/partners/bounties/claim-bounty-modal";
-import { StatusBadge } from "@dub/ui";
+import { DynamicTooltipWrapper, StatusBadge, TooltipContent } from "@dub/ui";
import { Calendar6, Gift } from "@dub/ui/icons";
import { cn, formatDate } from "@dub/utils";
+import { useParams } from "next/navigation";
export function PartnerBountyCard({ bounty }: { bounty: PartnerBountyProps }) {
+ const { programSlug } = useParams();
const { claimBountyModal, setShowClaimBountyModal } = useClaimBountyModal({
bounty,
});
@@ -18,65 +20,80 @@ export function PartnerBountyCard({ bounty }: { bounty: PartnerBountyProps }) {
return (
<>
{claimBountyModal}
- <button
- type="button"
- onClick={() => setShowClaimBountyModal(true)}
- disabled={expiredBounty}
- className={cn(
- "border-border-subtle group relative flex cursor-pointer flex-col gap-5 overflow-hidden rounded-xl border bg-white p-5 text-left",
+ <DynamicTooltipWrapper
+ tooltipProps={
expiredBounty
- ? "cursor-not-allowed"
- : "hover:border-border-default transition-all hover:shadow-lg",
- )}
+ ? {
+ content: (
+ <TooltipContent
+ title={`This bounty is no longer eligible for submission since it ended on ${formatDate(bounty.endsAt!, { month: "short" })}`}
+ cta="Contact program"
+ href={`/messages/${programSlug}`}
+ />
+ ),
+ }
+ : undefined
+ }
>
- <div className="relative flex h-[132px] items-center justify-center rounded-lg bg-neutral-100 py-1.5">
- <div className="relative size-full">
- <BountyThumbnailImage bounty={bounty} />
- </div>
+ <button
+ type="button"
+ onClick={() => setShowClaimBountyModal(true)}
+ disabled={expiredBounty}
+ className={cn(
+ "border-border-subtle group relative flex w-full cursor-pointer flex-col gap-5 overflow-hidden rounded-xl border bg-white p-5 text-left",
+ expiredBounty
+ ? "cursor-not-allowed"
+ : "hover:border-border-default transition-all hover:shadow-lg",
+ )}
+ >
+ <div className="relative flex h-[132px] items-center justify-center rounded-lg bg-neutral-100 py-1.5">
+ <div className="relative size-full">
+ <BountyThumbnailImage bounty={bounty} />
+ </div>
- {expiredBounty && (
- <div className="absolute left-2 top-2 z-10">
- <div className="flex h-5 items-center gap-1 rounded-md bg-red-100 px-2 py-1 text-xs font-semibold text-red-600">
- Expired {formatDate(bounty.endsAt!, { month: "short" })}
+ {expiredBounty && (
+ <div className="absolute left-2 top-2 z-10">
+ <div className="flex h-5 items-center gap-1 rounded-md bg-red-100 px-2 py-1 text-xs font-semibold text-red-600">
+ Expired {formatDate(bounty.endsAt!, { month: "short" })}
+ </div>
</div>
+ )}
+ </div>
+
+ <div className="flex min-w-0 flex-col gap-1.5">
+ <h3 className="text-content-emphasis truncate text-sm font-semibold">
+ {bounty.name}
+ </h3>
+
+ <div className="text-content-subtle flex items-center gap-2 text-sm font-medium">
+ <Calendar6 className="size-3.5" />
+ <span>
+ {formatDate(bounty.startsAt, { month: "short" })}
+ {bounty.endsAt && (
+ <>
+ {" → "}
+ {formatDate(bounty.endsAt, { month: "short" })}
+ </>
+ )}
+ </span>
</div>
- )}
- </div>
- <div className="flex min-w-0 flex-col gap-1.5">
- <h3 className="text-content-emphasis truncate text-sm font-semibold">
- {bounty.name}
- </h3>
-
- <div className="text-content-subtle flex items-center gap-2 text-sm font-medium">
- <Calendar6 className="size-3.5" />
- <span>
- {bounty.endsAt ? (
- <>
- End{expiredBounty ? "ed" : "s"}{" "}
- {formatDate(bounty.endsAt, { month: "short" })}
- </>
- ) : (
- "No end date"
- )}
- </span>
+ <div className="text-content-subtle flex items-center gap-2 text-sm font-medium">
+ <Gift className="size-3.5 shrink-0" />
+ <span className="truncate">
+ {getBountyRewardDescription(bounty)}
+ </span>
+ </div>
</div>
- <div className="text-content-subtle flex items-center gap-2 text-sm font-medium">
- <Gift className="size-3.5 shrink-0" />
- <span className="truncate">
- {getBountyRewardDescription(bounty)}
- </span>
+ <div className="flex grow flex-col justify-end">
+ {renderSubmissionStatus({
+ bounty,
+ setShowClaimBountyModal,
+ })}
</div>
- </div>
-
- <div className="flex grow flex-col justify-end">
- {renderSubmissionStatus({
- bounty,
- setShowClaimBountyModal,
- })}
- </div>
- </button>
+ </button>
+ </DynamicTooltipWrapper>
</>
);
}
@@ -107,6 +124,9 @@ function renderSubmissionStatus({
bounty: PartnerBountyProps;
setShowClaimBountyModal: (show: boolean) => void;
}) {
+ const expiredBounty =
+ bounty.endsAt && new Date(bounty.endsAt) < new Date() ? true : false;
+
const { submission } = bounty;
// When there is no submission, we show the performance or claim bounty button
if (!submission) {
@@ -114,7 +134,12 @@ function renderSubmissionStatus({
<BountyPerformance bounty={bounty} />
) : (
<div
- className="group-hover:ring-border-subtle flex h-7 w-fit items-center rounded-lg bg-black px-2.5 text-sm text-white transition-all group-hover:ring-2"
+ className={cn(
+ "flex h-7 w-fit items-center rounded-lg bg-black px-2.5 text-sm text-white",
+ expiredBounty
+ ? "cursor-not-allowed border border-neutral-200 bg-neutral-100 text-neutral-400"
+ : "group-hover:ring-border-subtle transition-all group-hover:ring-2",
+ )}
onClick={() => setShowClaimBountyModal(true)}
>
Claim bounty
diff --git a/apps/web/ui/partners/bounties/bounty-performance.tsx b/apps/web/ui/partners/bounties/bounty-performance.tsx
index 8be562d644..e398ae734e 100644
--- a/apps/web/ui/partners/bounties/bounty-performance.tsx
+++ b/apps/web/ui/partners/bounties/bounty-performance.tsx
@@ -1,7 +1,7 @@
import { PERFORMANCE_BOUNTY_SCOPE_ATTRIBUTES } from "@/lib/api/bounties/performance-bounty-scope-attributes";
import { isCurrencyAttribute } from "@/lib/api/workflows/utils";
import { PartnerBountyProps } from "@/lib/types";
-import { currencyFormatter, nFormatter } from "@dub/utils";
+import { cn, currencyFormatter, nFormatter } from "@dub/utils";
export function BountyPerformance({ bounty }: { bounty: PartnerBountyProps }) {
const performanceCondition = bounty.performanceCondition;
@@ -30,6 +30,9 @@ export function BountyPerformance({ bounty }: { bounty: PartnerBountyProps }) {
performanceCondition.attribute
].toLowerCase();
+ const expiredBounty =
+ bounty.endsAt && new Date(bounty.endsAt) < new Date() ? true : false;
+
return (
<div className="flex flex-col gap-2">
<div className="h-1.5 w-full overflow-hidden rounded-full bg-neutral-200">
@@ -38,7 +41,10 @@ export function BountyPerformance({ bounty }: { bounty: PartnerBountyProps }) {
style={{
width: Math.min(Math.max(value / target, 0), 1) * 100 + "%",
}}
- className="h-full rounded-full bg-orange-600"
+ className={cn(
+ "h-full rounded-full bg-orange-600",
+ expiredBounty && "bg-neutral-400",
+ )}
/>
)}
</div>
diff --git a/packages/ui/src/tooltip.tsx b/packages/ui/src/tooltip.tsx
index 41dfdcaa3d..415bd51c71 100644
--- a/packages/ui/src/tooltip.tsx
+++ b/packages/ui/src/tooltip.tsx
@@ -110,7 +110,7 @@ export function TooltipContent({
{...(target ? { target } : {})}
className={cn(
buttonVariants({ variant: "primary" }),
- "flex h-9 w-full items-center justify-center whitespace-nowrap rounded-lg border px-4 text-sm",
+ "flex h-8 w-full items-center justify-center whitespace-nowrap rounded-lg border px-4 text-sm",
)}
>
{cta}
@@ -120,7 +120,7 @@ export function TooltipContent({
onClick={onClick}
text={cta}
variant="primary"
- className="h-9"
+ className="h-8"
/>
) : null)}
</div>