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.

final updates

Steven Tey7f3ee4c02089
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/rewards/rewards.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/rewards/rewards.tsx
index 7b47fd38a6..68cdeccc81 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/rewards/rewards.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/rewards/rewards.tsx
@@ -264,7 +264,6 @@ const RewardItem = ({
{reward ? (
<ProgramRewardDescription
reward={reward}
- hideIfZero={false}
amountClassName="text-blue-600"
/>
) : (
diff --git a/apps/web/ui/partners/format-reward-description.ts b/apps/web/ui/partners/format-reward-description.ts
index 56ecd7f615..13586013f5 100644
--- a/apps/web/ui/partners/format-reward-description.ts
+++ b/apps/web/ui/partners/format-reward-description.ts
@@ -1,6 +1,5 @@
import { constructRewardAmount } from "@/lib/api/sales/construct-reward-amount";
import { RewardProps } from "@/lib/types";
-import { pluralize } from "@dub/utils";
export function formatRewardDescription({
reward,
@@ -10,18 +9,23 @@ export function formatRewardDescription({
const rewardAmount = constructRewardAmount(reward);
const parts: string[] = [];
- parts.push(`${rewardAmount} per ${reward.event}`);
+ parts.push("Earn");
+ parts.push(rewardAmount);
- if (reward.event === "sale") {
- if (reward.maxDuration === null) {
- parts.push("for the customer's lifetime");
- } else if (reward.maxDuration === 0) {
- parts.push("for the first purchase");
- } else if (reward.maxDuration && reward.maxDuration > 0) {
- parts.push(
- `for ${reward.maxDuration} ${pluralize("month", reward.maxDuration)}`,
- );
- }
+ if (reward.event === "sale" && reward.maxDuration === 0) {
+ parts.push("for the first sale");
+ } else {
+ parts.push(`per ${reward.event}`);
+ }
+
+ if (reward.maxDuration === null) {
+ parts.push("for the customer's lifetime");
+ } else if (reward.maxDuration && reward.maxDuration > 1) {
+ const durationText =
+ reward.maxDuration % 12 === 0
+ ? `${reward.maxDuration / 12} year${reward.maxDuration / 12 > 1 ? "s" : ""}`
+ : `${reward.maxDuration} months`;
+ parts.push(`for ${durationText}`);
}
return parts.join(" ");
diff --git a/apps/web/ui/partners/program-reward-description.tsx b/apps/web/ui/partners/program-reward-description.tsx
index 536de29fc0..1da5e48675 100644
--- a/apps/web/ui/partners/program-reward-description.tsx
+++ b/apps/web/ui/partners/program-reward-description.tsx
@@ -7,7 +7,6 @@ export function ProgramRewardDescription({
discount,
amountClassName,
periodClassName,
- hideIfZero = true,
}: {
reward?: Pick<
RewardProps,
@@ -16,11 +15,10 @@ export function ProgramRewardDescription({
discount?: DiscountProps | null;
amountClassName?: string;
periodClassName?: string;
- hideIfZero?: boolean; // if true, don't display the reward description if the reward amount is 0
}) {
return (
<>
- {reward && (reward.amount > 0 || !hideIfZero)
+ {reward
? reward.description || (
<>
Earn{" "}
@@ -37,24 +35,23 @@ export function ProgramRewardDescription({
)}
{reward.maxDuration === null ? (
<>
- {" "}for the{" "}
- <strong className={cn("font-semibold", periodClassName)}>
- customer's lifetime.
- </strong>
+ {" "}
+ for the{" "}
+ <strong className={cn("font-semibold", periodClassName)}>
+ customer's lifetime
+ </strong>
</>
) : reward.maxDuration && reward.maxDuration > 1 ? (
<>
- {" "}for{" "}
+ {" "}
+ for{" "}
<strong className={cn("font-semibold", periodClassName)}>
{reward.maxDuration % 12 === 0
- ? `${reward.maxDuration / 12} year${reward.maxDuration / 12 > 1 ? 's' : ''}`
+ ? `${reward.maxDuration / 12} year${reward.maxDuration / 12 > 1 ? "s" : ""}`
: `${reward.maxDuration} months`}
</strong>
- .
</>
- ) : (
- "."
- )}
+ ) : null}
</>
)
: null}
@@ -83,7 +80,6 @@ export function ProgramRewardDescription({
) : (
" for their first purchase"
)}
- .
</strong>
</>
) : null}
diff --git a/apps/web/ui/partners/program-reward-list.tsx b/apps/web/ui/partners/program-reward-list.tsx
index c7008094cf..6e352ccfd3 100644
--- a/apps/web/ui/partners/program-reward-list.tsx
+++ b/apps/web/ui/partners/program-reward-list.tsx
@@ -38,18 +38,21 @@ export function ProgramRewardList({
)}
{reward.maxDuration === null ? (
<>
- {" "}for the{" "}
- <strong className={cn("font-semibold")}>customer's lifetime.</strong>
+ {" "}
+ for the{" "}
+ <strong className={cn("font-semibold")}>
+ customer's lifetime
+ </strong>
</>
) : reward.maxDuration && reward.maxDuration > 1 ? (
<>
- {" "}for{" "}
+ {" "}
+ for{" "}
<strong className={cn("font-semibold")}>
{reward.maxDuration % 12 === 0
- ? `${reward.maxDuration / 12} year${reward.maxDuration / 12 > 1 ? 's' : ''}`
+ ? `${reward.maxDuration / 12} year${reward.maxDuration / 12 > 1 ? "s" : ""}`
: `${reward.maxDuration} months`}
</strong>
- .
</>
) : null}
</>