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.

support custom reward descriptions

Steven Tey551f565f89dc
diff --git a/apps/web/lib/zod/schemas/rewards.ts b/apps/web/lib/zod/schemas/rewards.ts
index a618d33bf2..0ff9903230 100644
--- a/apps/web/lib/zod/schemas/rewards.ts
+++ b/apps/web/lib/zod/schemas/rewards.ts
@@ -19,6 +19,7 @@ export const RewardSchema = z.object({
id: z.string(),
event: z.nativeEnum(EventType),
name: z.string().nullish(),
+ description: z.string().nullish(),
type: z.nativeEnum(CommissionType),
amount: z.number(),
maxDuration: z.number().nullish(),
diff --git a/apps/web/ui/partners/program-reward-description.tsx b/apps/web/ui/partners/program-reward-description.tsx
index 27afe8b77f..e865c80ad4 100644
--- a/apps/web/ui/partners/program-reward-description.tsx
+++ b/apps/web/ui/partners/program-reward-description.tsx
@@ -11,7 +11,7 @@ export function ProgramRewardDescription({
}: {
reward?: Pick<
RewardProps,
- "amount" | "type" | "event" | "maxDuration"
+ "amount" | "type" | "event" | "maxDuration" | "description"
> | null;
discount?: DiscountProps | null;
amountClassName?: string;
@@ -20,34 +20,36 @@ export function ProgramRewardDescription({
}) {
return (
<>
- {reward && (reward.amount > 0 || !hideIfZero) ? (
- <>
- Earn{" "}
- <strong className={cn("font-semibold", amountClassName)}>
- {constructRewardAmount({
- amount: reward.amount,
- type: reward.type,
- })}{" "}
- </strong>
- for each {reward.event}
- {reward.maxDuration === null ? (
- <strong className={cn("font-semibold", periodClassName)}>
- {" "}
- for the customer's lifetime.
- </strong>
- ) : reward.maxDuration && reward.maxDuration > 1 ? (
+ {reward && (reward.amount > 0 || !hideIfZero)
+ ? reward.description || (
<>
- , and again{" "}
- <strong className={cn("font-semibold", periodClassName)}>
- every month for {reward.maxDuration} months
+ Earn{" "}
+ <strong className={cn("font-semibold", amountClassName)}>
+ {constructRewardAmount({
+ amount: reward.amount,
+ type: reward.type,
+ })}{" "}
</strong>
- .
+ for each {reward.event}
+ {reward.maxDuration === null ? (
+ <strong className={cn("font-semibold", periodClassName)}>
+ {" "}
+ for the customer's lifetime.
+ </strong>
+ ) : reward.maxDuration && reward.maxDuration > 1 ? (
+ <>
+ , and again{" "}
+ <strong className={cn("font-semibold", periodClassName)}>
+ every month for {reward.maxDuration} months
+ </strong>
+ .
+ </>
+ ) : (
+ "."
+ )}
</>
- ) : (
- "."
- )}
- </>
- ) : null}
+ )
+ : null}
{discount ? (
<>
diff --git a/apps/web/ui/partners/program-reward-list.tsx b/apps/web/ui/partners/program-reward-list.tsx
index d787d2fc01..e034309905 100644
--- a/apps/web/ui/partners/program-reward-list.tsx
+++ b/apps/web/ui/partners/program-reward-list.tsx
@@ -25,16 +25,20 @@ export function ProgramRewardList({
>
{sortedFilteredRewards.map((reward) => (
<Item key={reward.id} icon={REWARD_EVENTS[reward.event].icon}>
- {constructRewardAmount({
- amount: reward.amount,
- type: reward.type,
- })}{" "}
- per {reward.event}
- {reward.maxDuration === null ? (
- <> for the customer's lifetime</>
- ) : reward.maxDuration && reward.maxDuration > 1 ? (
- <>, and again every month for {reward.maxDuration} months</>
- ) : null}
+ {reward.description || (
+ <>
+ {constructRewardAmount({
+ amount: reward.amount,
+ type: reward.type,
+ })}{" "}
+ per {reward.event}
+ {reward.maxDuration === null ? (
+ <> for the customer's lifetime</>
+ ) : reward.maxDuration && reward.maxDuration > 1 ? (
+ <>, and again every month for {reward.maxDuration} months</>
+ ) : null}
+ </>
+ )}
</Item>
))}
{discount && (
diff --git a/packages/prisma/schema/program.prisma b/packages/prisma/schema/program.prisma
index 60979184df..c61ae1facb 100644
--- a/packages/prisma/schema/program.prisma
+++ b/packages/prisma/schema/program.prisma
@@ -39,6 +39,7 @@ model Program {
minPayoutAmount Int @default(10000) // Default minimum payout amount of $100
defaultRewardId String? @unique // default reward for the program
defaultDiscountId String? @unique // default discount for the program
+ embedData Json? @db.Json
landerData Json? @db.Json
resources Json? @db.Json
termsUrl String? @db.Text
diff --git a/packages/prisma/schema/reward.prisma b/packages/prisma/schema/reward.prisma
index cb370c7bd2..5b91f0dc4a 100644
--- a/packages/prisma/schema/reward.prisma
+++ b/packages/prisma/schema/reward.prisma
@@ -3,6 +3,7 @@ model Reward {
programId String
name String?
+ description String?
event EventType
type CommissionType @default(percentage)
amount Int @default(0)