The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Add program reward education and helper content (#3421)
Marcus Farrell05313c421422
diff --git a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/rewards/form.tsx b/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/rewards/form.tsxindex d4beb83e87..db4e39b9d1 100644--- a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/rewards/form.tsx+++ b/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/rewards/form.tsx@@ -18,12 +18,34 @@ const DEFAULT_REWARD_TYPES = [{key: "sale",label: "Sale",- description: "For sales and subscriptions",+ description: "When revenue is generated",+ mostCommon: true,},{key: "lead",label: "Lead",- description: "For sign ups and leads",+ description: "For sign ups and demos",+ mostCommon: false,+ },+] as const;++const COMMISSION_STRUCTURE_DESCRIPTIONS: Record<string, string> = {+ "one-off": "For referrals and fixed payouts",+ recurring: "For ongoing revenue share",+};++const PAYOUT_MODELS = [+ {+ key: "percentage",+ label: "Percentage",+ description: "Share of the revenue",+ mostCommon: true,+ },+ {+ key: "flat",+ label: "Flat",+ description: "Fixed amount per conversion",+ mostCommon: false,},] as const;@@ -40,15 +62,7 @@ export function Form() {formState: { isSubmitting },} = useFormContext<ProgramData>();- const [- amountInCents,- amountInPercentage,- type,- defaultRewardType,- maxDuration,- ] = watch([- "amountInCents",- "amountInPercentage",+ const [type, defaultRewardType, maxDuration] = watch(["type","defaultRewardType","maxDuration",@@ -94,9 +108,6 @@ export function Form() {});};- const amount = type === "flat" ? amountInCents : amountInPercentage;- const buttonDisabled = amount == null || !type || !defaultRewardType;-return (<form onSubmit={handleSubmit(onSubmit)} className="space-y-10"><div className="flex flex-col gap-10">@@ -111,50 +122,74 @@ export function Form() {</div><div className="grid grid-cols-1 gap-3 lg:grid-cols-2">- {DEFAULT_REWARD_TYPES.map(({ key, label, description }) => {- const isSelected = key === defaultRewardType;-- return (- <label- key={key}- className={cn(- "relative flex w-full cursor-pointer items-start gap-0.5 rounded-md border border-neutral-200 bg-white p-3 text-neutral-600 hover:bg-neutral-50",- "transition-all duration-150",- isSelected &&- "border-black bg-neutral-50 text-neutral-900 ring-1 ring-black",- )}- >- <input- type="radio"- value={key}- className="hidden"- checked={isSelected}- onChange={() => {- setValue("defaultRewardType", key, { shouldDirty: true });+ {DEFAULT_REWARD_TYPES.map(+ ({ key, label, description, mostCommon }) => {+ const isSelected = key === defaultRewardType;- if (key === "lead") {- setValue("type", "flat", { shouldDirty: true });- setValue("maxDuration", 0, { shouldDirty: true });- }- }}- />- <div className="flex grow flex-col text-sm">- <span className="text-sm font-semibold text-neutral-900">- {label}- </span>- <span className="text-sm font-normal text-neutral-600">- {description}- </span>- </div>- <CircleCheckFill+ return (+ <div+ key={key}className={cn(- "-mr-px -mt-px flex size-4 scale-75 items-center justify-center rounded-full opacity-0 transition-[transform,opacity] duration-150",- isSelected && "scale-100 opacity-100",+ "flex flex-col items-center",+ mostCommon &&+ "rounded-md border border-neutral-200 bg-neutral-100",)}- />- </label>- );- })}+ >+ <label+ className={cn(+ "relative flex w-full cursor-pointer items-start gap-0.5 rounded-md border border-neutral-200 bg-white p-3 text-neutral-600 hover:bg-neutral-50",+ "transition-all duration-150",+ mostCommon && "border-transparent shadow-sm",+ isSelected &&+ "border-black bg-neutral-50 text-neutral-900 ring-1 ring-black",+ )}+ >+ <input+ type="radio"+ value={key}+ className="hidden"+ checked={isSelected}+ onChange={() => {+ setValue("defaultRewardType", key, {+ shouldDirty: true,+ });++ if (key === "sale") {+ setValue("type", "percentage", {+ shouldDirty: true,+ });+ }++ if (key === "lead") {+ setValue("type", "flat", { shouldDirty: true });+ setValue("maxDuration", 0, { shouldDirty: true });+ }+ }}+ />+ <div className="flex grow flex-col text-sm">+ <span className="text-sm font-semibold text-neutral-900">+ {label}+ </span>+ <span className="text-sm font-normal text-neutral-600">+ {description}+ </span>+ </div>+ <CircleCheckFill+ className={cn(+ "-mr-px -mt-px flex size-4 scale-75 items-center justify-center rounded-full opacity-0 transition-[transform,opacity] duration-150",+ isSelected && "scale-100 opacity-100",+ )}+ />+ </label>+ {mostCommon && (+ <span className="py-0.5 text-xs font-medium text-neutral-500">+ Most common+ </span>+ )}+ </div>+ );+ },+ )}</div></div>@@ -170,53 +205,69 @@ export function Form() {</div><div className="grid grid-cols-1 gap-3 lg:grid-cols-2">- {COMMISSION_TYPES.map(({ value, label, description }) => {+ {COMMISSION_TYPES.map(({ value, label }) => {const isSelected = value === commissionStructure;return (- <label+ <divkey={value}className={cn(- "relative flex w-full cursor-pointer items-start gap-0.5 rounded-md border border-neutral-200 bg-white p-3 text-neutral-600 hover:bg-neutral-50",- "transition-all duration-150",- isSelected &&- "border-black bg-neutral-50 text-neutral-900 ring-1 ring-black",+ "flex flex-col items-center",+ value === "recurring" &&+ "rounded-md border border-neutral-200 bg-neutral-100",)}>- <input- type="radio"- value={value}- className="hidden"- checked={isSelected}- onChange={(e) => {- if (value === "one-off") {- setCommissionStructure("one-off");- setValue("maxDuration", 0, { shouldValidate: true });- }-- if (value === "recurring") {- setCommissionStructure("recurring");- setValue("maxDuration", 12, {- shouldValidate: true,- });- }- }}- />- <div className="flex grow flex-col text-sm">- <span className="text-sm font-semibold text-neutral-900">- {label}- </span>- <span className="text-sm font-normal text-neutral-600">- {description}- </span>- </div>- <CircleCheckFill+ <labelclassName={cn(- "-mr-px -mt-px flex size-4 scale-75 items-center justify-center rounded-full opacity-0 transition-[transform,opacity] duration-150",- isSelected && "scale-100 opacity-100",+ "relative flex w-full cursor-pointer items-start gap-0.5 rounded-md border border-neutral-200 bg-white p-3 text-neutral-600 hover:bg-neutral-50",+ "transition-all duration-150",+ value === "recurring" && "border-transparent shadow-sm",+ isSelected &&+ "border-black bg-neutral-50 text-neutral-900 ring-1 ring-black",)}- />- </label>+ >+ <input+ type="radio"+ value={value}+ className="hidden"+ checked={isSelected}+ onChange={() => {+ if (value === "one-off") {+ setCommissionStructure("one-off");+ setValue("maxDuration", 0, {+ shouldValidate: true,+ });+ }++ if (value === "recurring") {+ setCommissionStructure("recurring");+ setValue("maxDuration", null, {+ shouldValidate: true,+ });+ }+ }}+ />+ <div className="flex grow flex-col text-sm">+ <span className="text-sm font-semibold text-neutral-900">+ {label}+ </span>+ <span className="text-sm font-normal text-neutral-600">+ {COMMISSION_STRUCTURE_DESCRIPTIONS[value]}+ </span>+ </div>+ <CircleCheckFill+ className={cn(+ "-mr-px -mt-px flex size-4 scale-75 items-center justify-center rounded-full opacity-0 transition-[transform,opacity] duration-150",+ isSelected && "scale-100 opacity-100",+ )}+ />+ </label>+ {value === "recurring" && (+ <span className="py-0.5 text-xs font-medium text-neutral-500">+ Most common+ </span>+ )}+ </div>);})}</div>@@ -238,18 +289,14 @@ export function Form() {})}className="mt-2 block w-full rounded-md border border-neutral-300 bg-white py-2 pl-3 pr-10 text-sm text-neutral-900 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500">+ <option value="">Lifetime</option>{RECURRING_MAX_DURATIONS.filter((v) => v !== 0 && v !== 1, // filter out one-time and 1-month intervals (we only use 1-month for discounts)).map((duration) => (- <option- key={duration}- value={duration}- selected={duration === 12}- >- {duration} {duration === 1 ? "month" : "months"}+ <option key={duration} value={duration}>+ {duration} months</option>))}- <option value="">Lifetime</option></select></div>)}@@ -267,23 +314,69 @@ export function Form() {</div>{defaultRewardType === "sale" && (- <div>- <label className="text-sm font-medium text-neutral-800">- Reward structure- </label>- <select- {...register("type")}- className="mt-2 block w-full rounded-md border border-neutral-300 bg-white py-2 pl-3 pr-10 text-sm text-neutral-900 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500"- >- <option value="flat">Flat</option>- <option value="percentage">Percentage</option>- </select>+ <div className="grid grid-cols-1 gap-3 lg:grid-cols-2">+ {PAYOUT_MODELS.map(+ ({ key, label, description, mostCommon }) => {+ const isSelected = key === type;++ return (+ <div+ key={key}+ className={cn(+ "flex flex-col items-center",+ mostCommon &&+ "rounded-md border border-neutral-200 bg-neutral-100",+ )}+ >+ <label+ className={cn(+ "relative flex w-full cursor-pointer items-start gap-0.5 rounded-md border border-neutral-200 bg-white p-3 text-neutral-600 hover:bg-neutral-50",+ "transition-all duration-150",+ mostCommon && "border-transparent shadow-sm",+ isSelected &&+ "border-black bg-neutral-50 text-neutral-900 ring-1 ring-black",+ )}+ >+ <input+ type="radio"+ value={key}+ className="hidden"+ checked={isSelected}+ onChange={() =>+ setValue("type", key, { shouldDirty: true })+ }+ />+ <div className="flex grow flex-col text-sm">+ <span className="text-sm font-semibold text-neutral-900">+ {label}+ </span>+ <span className="text-sm font-normal text-neutral-600">+ {description}+ </span>+ </div>+ <CircleCheckFill+ className={cn(+ "-mr-px -mt-px flex size-4 scale-75 items-center justify-center rounded-full opacity-0 transition-[transform,opacity] duration-150",+ isSelected && "scale-100 opacity-100",+ )}+ />+ </label>+ {mostCommon && (+ <span className="py-0.5 text-xs font-medium text-neutral-500">+ Most common+ </span>+ )}+ </div>+ );+ },+ )}</div>)}<div><label className="text-sm font-medium text-neutral-800">- Reward amount {defaultRewardType != "sale" ? "per lead" : ""}+ {type === "percentage" ? "Percentage" : "Amount"} per{" "}+ {defaultRewardType}</label><div className="relative mt-2 rounded-md shadow-sm"><span className="absolute inset-y-0 left-0 flex items-center pl-3 text-sm text-neutral-400">@@ -318,7 +411,7 @@ export function Form() {text="Continue"className="w-full"loading={isSubmitting || isPending}- disabled={buttonDisabled || hasSubmitted}+ disabled={hasSubmitted}type="submit"/></form>diff --git a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/rewards/page.tsx b/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/rewards/page.tsxindex 3e7f8aafe1..ba530799e1 100644--- a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/rewards/page.tsx+++ b/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/rewards/page.tsx@@ -3,7 +3,7 @@ import { Form } from "./form";export default async function ProgramOnboardingRewardsPage() {return (- <StepPage title="Configure rewards">+ <StepPage title="Create default reward"><Form /></StepPage>);diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/discounts/group-discounts.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/discounts/group-discounts.tsxindex d7c7667d0b..bef3caf02c 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/discounts/group-discounts.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/discounts/group-discounts.tsx@@ -5,25 +5,15 @@ import type { DiscountProps, GroupProps } from "@/lib/types";import { DEFAULT_PARTNER_GROUP } from "@/lib/zod/schemas/groups";import { useDiscountSheet } from "@/ui/partners/discounts/add-edit-discount-sheet";import { ProgramRewardDescription } from "@/ui/partners/program-reward-description";-import { X } from "@/ui/shared/icons";-import {- Button,- buttonVariants,- Discount,- Grid,- useLocalStorage,-} from "@dub/ui";+import { Button } from "@dub/ui";import { cn, isClickOnInteractiveChild } from "@dub/utils";import { BadgePercent } from "lucide-react";-import { motion } from "motion/react";export const GroupDiscounts = () => {const { group, loading } = useGroup();return (<div>- <Banner />-{loading || !group ? (<DiscountSkeleton />) : (@@ -132,77 +122,3 @@ const DiscountSkeleton = () => {);};-const Banner = () => {- const [dismissedBanner, setDismissedBanner] = useLocalStorage<boolean>(- "program-discount-banner-dismissed",- false,- );-- return (- <motion.div- animate={- dismissedBanner- ? { opacity: 0, height: 0 }- : { opacity: 1, height: "auto" }- }- initial={false}- className="overflow-hidden"- inert={dismissedBanner}- >- <div className="pb-6">- <div className="relative isolate overflow-hidden rounded-xl bg-neutral-100">- <div- className="pointer-events-none absolute inset-0 [mask-image:linear-gradient(90deg,transparent,black)]"- aria-hidden- >- <div className="absolute right-0 top-0 h-full w-[600px]">- <Grid- cellSize={60}- patternOffset={[1, -30]}- className="text-neutral-200"- />- </div>- <div className="absolute -inset-16 opacity-15 blur-[50px] [transform:translateZ(0)]">- <div- className="absolute right-0 top-0 h-full w-[350px] -scale-y-100 rounded-l-full saturate-150"- style={{- backgroundImage: `conic-gradient(from -66deg, #855AFC -32deg, #FF0000 63deg, #EAB308 158deg, #5CFF80 240deg, #855AFC 328deg, #FF0000 423deg)`,- }}- />- </div>- </div>- <div className="relative flex flex-col gap-4 p-5">- <Discount className="size-6" />- <div>- <h2 className="text-content-emphasis text-base font-semibold">- Referral discounts- </h2>- <p className="text-content-subtle text-base font-normal leading-6">- Discounts offered to customers when referred by partners in this- group- </p>- </div>- <a- href="https://dub.co/help/article/dual-sided-incentives"- target="_blank"- className={cn(- buttonVariants({ variant: "secondary" }),- "flex h-8 w-fit items-center rounded-lg border bg-white px-3 text-sm",- )}- >- Learn more- </a>- </div>-- <button- type="button"- className="text-content-emphasis absolute right-4 top-4 flex size-7 items-center justify-center rounded-lg transition-colors duration-150 hover:bg-black/5 active:bg-black/10"- onClick={() => setDismissedBanner(true)}- >- <X className="size-4" />- </button>- </div>- </div>- </motion.div>- );-};diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/rewards/group-rewards.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/rewards/group-rewards.tsxindex cc815015f5..abf3e33e00 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/rewards/group-rewards.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/rewards/group-rewards.tsx@@ -9,22 +9,31 @@ import {RewardSheet,useRewardSheet,} from "@/ui/partners/rewards/add-edit-reward-sheet";-import { X } from "@/ui/shared/icons";import { EventType } from "@dub/prisma/client";-import {- Button,- buttonVariants,- Gift,- Grid,- useLocalStorage,- useRouterStuff,-} from "@dub/ui";+import { Button, useRouterStuff } from "@dub/ui";import { cn } from "@dub/utils";-import { motion } from "motion/react";import Link from "next/link";import { useParams } from "next/navigation";import { useEffect, useState } from "react";+const REWARD_EVENT_DESCRIPTIONS: Record<+ EventType,+ { title: string; description: string }+> = {+ sale: {+ title: "Sale reward",+ description: "Reward when revenue is generated",+ },+ lead: {+ title: "Lead reward",+ description: "Reward for sign ups or demos",+ },+ click: {+ title: "Click reward",+ description: "Reward for traffic and reach",+ },+};+export function GroupRewards() {const { group, loading } = useGroup();const { searchParams } = useRouterStuff();@@ -69,8 +78,6 @@ export function GroupRewards() {/>)}- <Banner />-<div className="flex flex-col gap-6">{loading || !group ? (<>@@ -157,18 +164,23 @@ const RewardItem = ({</div><div className="flex flex-1 flex-col justify-between gap-y-4 md:flex-row md:items-center"><div className="flex items-center gap-2">- <span className="text-sm font-normal">- {reward ? (+ {reward ? (+ <span className="text-sm font-normal"><ProgramRewardDescriptionreward={reward}amountClassName="text-blue-600"/>- ) : (- <span className="text-sm font-normal text-neutral-600">- No {event} reward configured+ </span>+ ) : (+ <div className="flex flex-col">+ <span className="text-sm font-medium text-neutral-900">+ {REWARD_EVENT_DESCRIPTIONS[event].title}</span>- )}- </span>+ <span className="text-sm font-normal text-neutral-500">+ {REWARD_EVENT_DESCRIPTIONS[event].description}+ </span>+ </div>+ )}</div>{reward ? (@@ -251,76 +263,3 @@ const RewardSkeleton = () => {);};-const Banner = () => {- const [dismissedBanner, setDismissedBanner] = useLocalStorage<boolean>(- "program-rewards-banner-dismissed",- false,- );-- return (- <motion.div- animate={- dismissedBanner- ? { opacity: 0, height: 0 }- : { opacity: 1, height: "auto" }- }- initial={false}- className="overflow-hidden"- inert={dismissedBanner}- >- <div className="pb-6">- <div className="relative isolate overflow-hidden rounded-xl bg-neutral-100">- <div- className="pointer-events-none absolute inset-0 [mask-image:linear-gradient(90deg,transparent,black)]"- aria-hidden- >- <div className="absolute right-0 top-0 h-full w-[600px]">- <Grid- cellSize={60}- patternOffset={[1, -30]}- className="text-neutral-200"- />- </div>- <div className="absolute -inset-16 opacity-15 blur-[50px] [transform:translateZ(0)]">- <div- className="absolute right-0 top-0 h-full w-[350px] -scale-y-100 rounded-l-full saturate-150"- style={{- backgroundImage: `conic-gradient(from -66deg, #855AFC -32deg, #FF0000 63deg, #EAB308 158deg, #5CFF80 240deg, #855AFC 328deg, #FF0000 423deg)`,- }}- />- </div>- </div>- <div className="relative flex flex-col gap-4 p-5">- <Gift className="size-6" />- <div>- <h2 className="text-content-emphasis text-base font-semibold">- Rewards- </h2>- <p className="text-content-subtle text-base font-normal leading-6">- Rewards offered to all partners enrolled in this group- </p>- </div>- <a- href="https://dub.co/help/article/partner-rewards"- target="_blank"- className={cn(- buttonVariants({ variant: "secondary" }),- "flex h-8 w-fit items-center rounded-lg border bg-white px-3 text-sm",- )}- >- Learn more- </a>- </div>-- <button- type="button"- className="text-content-emphasis absolute right-4 top-4 flex size-7 items-center justify-center rounded-lg transition-colors duration-150 hover:bg-black/5 active:bg-black/10"- onClick={() => setDismissedBanner(true)}- >- <X className="size-4" />- </button>- </div>- </div>- </motion.div>- );-};diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/reward/form.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/reward/form.tsxindex d7230f7f46..7dfed01008 100644--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/reward/form.tsx+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/reward/form.tsx@@ -18,12 +18,29 @@ const DEFAULT_REWARD_TYPES = [{key: "sale",label: "Sale",- description: "For purchases",+ description: "Paid revenue",+ mostCommon: true,},{key: "lead",label: "Lead",- description: "For sign ups",+ description: "Sign ups and demos",+ mostCommon: false,+ },+] as const;++const PAYOUT_MODELS = [+ {+ key: "percentage",+ label: "Percentage",+ description: "Revenue based",+ mostCommon: true,+ },+ {+ key: "flat",+ label: "Flat",+ description: "Fixed amount",+ mostCommon: false,},] as const;@@ -49,10 +66,13 @@ export function Form() {const [commissionStructure, setCommissionStructure] = useState<"one-off" | "recurring"- >("one-off");+ >("recurring");useEffect(- () => setCommissionStructure(maxDuration ? "recurring" : "one-off"),+ () =>+ setCommissionStructure(+ maxDuration === 0 ? "one-off" : "recurring",+ ),[maxDuration],);@@ -99,52 +119,74 @@ export function Form() {</h2><div className="grid grid-cols-1 gap-3 lg:grid-cols-2">- {DEFAULT_REWARD_TYPES.map(({ key, label, description }) => {- const isSelected = key === defaultRewardType;+ {DEFAULT_REWARD_TYPES.map(+ ({ key, label, description, mostCommon }) => {+ const isSelected = key === defaultRewardType;- return (- <label- key={key}- className={cn(- "relative flex w-full cursor-pointer items-start gap-0.5 rounded-md border border-neutral-200 bg-white p-3 text-neutral-600 hover:bg-neutral-50",- "transition-all duration-150",- isSelected &&- "border-black bg-neutral-50 text-neutral-900 ring-1 ring-black",- )}- >- <input- type="radio"- value={key}- className="hidden"- checked={isSelected}- onChange={() => {- setValue("defaultRewardType", key, {- shouldDirty: true,- });-- if (key === "lead") {- setValue("type", "flat", { shouldDirty: true });- setValue("maxDuration", 0, { shouldDirty: true });- }- }}- />- <div className="flex grow flex-col text-sm">- <span className="text-sm font-semibold text-neutral-900">- {label}- </span>- <span className="text-sm font-normal text-neutral-600">- {description}- </span>- </div>- <CircleCheckFill+ return (+ <div+ key={key}className={cn(- "-mr-px -mt-px flex size-4 scale-75 items-center justify-center rounded-full opacity-0 transition-[transform,opacity] duration-150",- isSelected && "scale-100 opacity-100",+ "flex flex-col items-center",+ mostCommon &&+ "rounded-md border border-neutral-200 bg-neutral-100",)}- />- </label>- );- })}+ >+ <label+ className={cn(+ "relative flex w-full cursor-pointer items-start gap-0.5 rounded-md border border-neutral-200 bg-white p-3 text-neutral-600 hover:bg-neutral-50",+ "transition-all duration-150",+ mostCommon && "border-transparent shadow-sm",+ isSelected &&+ "border-black bg-neutral-50 text-neutral-900 ring-1 ring-black",+ )}+ >+ <input+ type="radio"+ value={key}+ className="hidden"+ checked={isSelected}+ onChange={() => {+ setValue("defaultRewardType", key, {+ shouldDirty: true,+ });++ if (key === "sale") {+ setValue("type", "percentage", {+ shouldDirty: true,+ });+ }++ if (key === "lead") {+ setValue("type", "flat", { shouldDirty: true });+ setValue("maxDuration", 0, { shouldDirty: true });+ }+ }}+ />+ <div className="flex grow flex-col text-sm">+ <span className="text-sm font-semibold text-neutral-900">+ {label}+ </span>+ <span className="text-sm font-normal text-neutral-600">+ {description}+ </span>+ </div>+ <CircleCheckFill+ className={cn(+ "-mr-px -mt-px flex size-4 scale-75 items-center justify-center rounded-full opacity-0 transition-[transform,opacity] duration-150",+ isSelected && "scale-100 opacity-100",+ )}+ />+ </label>+ {mostCommon && (+ <span className="py-0.5 text-xs font-medium text-neutral-500">+ Most common+ </span>+ )}+ </div>+ );+ },+ )}</div></div>@@ -166,51 +208,66 @@ export function Form() {const isSelected = value === commissionStructure;return (- <label+ <divkey={value}className={cn(- "relative flex w-full cursor-pointer items-start gap-0.5 rounded-md border border-neutral-200 bg-white p-3 text-neutral-600 hover:bg-neutral-50",- "transition-all duration-150",- isSelected &&- "border-black bg-neutral-50 text-neutral-900 ring-1 ring-black",+ "flex flex-col items-center",+ value === "recurring" &&+ "rounded-md border border-neutral-200 bg-neutral-100",)}>- <input- type="radio"- value={value}- className="hidden"- checked={isSelected}- onChange={(e) => {- if (value === "one-off") {- setCommissionStructure("one-off");- setValue("maxDuration", 0, {- shouldValidate: true,- });- }-- if (value === "recurring") {- setCommissionStructure("recurring");- setValue("maxDuration", 12, {- shouldValidate: true,- });- }- }}- />- <div className="flex grow flex-col text-sm">- <span className="text-sm font-semibold text-neutral-900">- {label}- </span>- <span className="text-sm font-normal text-neutral-600">- {shortDescription}- </span>- </div>- <CircleCheckFill+ <labelclassName={cn(- "-mr-px -mt-px flex size-4 scale-75 items-center justify-center rounded-full opacity-0 transition-[transform,opacity] duration-150",- isSelected && "scale-100 opacity-100",+ "relative flex w-full cursor-pointer items-start gap-0.5 rounded-md border border-neutral-200 bg-white p-3 text-neutral-600 hover:bg-neutral-50",+ "transition-all duration-150",+ value === "recurring" &&+ "border-transparent shadow-sm",+ isSelected &&+ "border-black bg-neutral-50 text-neutral-900 ring-1 ring-black",)}- />- </label>+ >+ <input+ type="radio"+ value={value}+ className="hidden"+ checked={isSelected}+ onChange={() => {+ if (value === "one-off") {+ setCommissionStructure("one-off");+ setValue("maxDuration", 0, {+ shouldValidate: true,+ });+ }++ if (value === "recurring") {+ setCommissionStructure("recurring");+ setValue("maxDuration", null, {+ shouldValidate: true,+ });+ }+ }}+ />+ <div className="flex grow flex-col text-sm">+ <span className="text-sm font-semibold text-neutral-900">+ {label}+ </span>+ <span className="text-sm font-normal text-neutral-600">+ {shortDescription}+ </span>+ </div>+ <CircleCheckFill+ className={cn(+ "-mr-px -mt-px flex size-4 scale-75 items-center justify-center rounded-full opacity-0 transition-[transform,opacity] duration-150",+ isSelected && "scale-100 opacity-100",+ )}+ />+ </label>+ {value === "recurring" && (+ <span className="py-0.5 text-xs font-medium text-neutral-500">+ Most common+ </span>+ )}+ </div>);},)}@@ -236,36 +293,87 @@ export function Form() {})}className="block w-full rounded-md border border-neutral-300 bg-white py-2 pl-3 pr-10 text-sm text-neutral-900 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500">+ <option value="">Lifetime</option>{RECURRING_MAX_DURATIONS.filter((v) => v !== 0 && v !== 1, // filter out one-time and 1-month intervals (we only use 1-month for discounts)).map((duration) => (<option key={duration} value={duration}>- {duration} {duration === 1 ? "month" : "months"}+ {duration} months</option>))}- <option value="">Lifetime</option></select></label>)}{defaultRewardType === "sale" && (- <label className="space-y-2">- <span className="text-content-emphasis block text-sm font-semibold">+ <div className="space-y-2">+ <h2 className="text-content-emphasis text-sm font-semibold">Payout model- </span>- <select- {...register("type")}- className="block w-full rounded-md border border-neutral-300 bg-white py-2 pl-3 pr-10 text-sm text-neutral-900 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500"- >- <option value="flat">Flat</option>- <option value="percentage">Percentage</option>- </select>- </label>+ </h2>+ <div className="grid grid-cols-1 gap-3 lg:grid-cols-2">+ {PAYOUT_MODELS.map(+ ({ key, label, description, mostCommon }) => {+ const isSelected = key === type;++ return (+ <div+ key={key}+ className={cn(+ "flex flex-col items-center",+ mostCommon &&+ "rounded-md border border-neutral-200 bg-neutral-100",+ )}+ >+ <label+ className={cn(+ "relative flex w-full cursor-pointer items-start gap-0.5 rounded-md border border-neutral-200 bg-white p-3 text-neutral-600 hover:bg-neutral-50",+ "transition-all duration-150",+ mostCommon && "border-transparent shadow-sm",+ isSelected &&+ "border-black bg-neutral-50 text-neutral-900 ring-1 ring-black",+ )}+ >+ <input+ type="radio"+ value={key}+ className="hidden"+ checked={isSelected}+ onChange={() =>+ setValue("type", key, { shouldDirty: true })+ }+ />+ <div className="flex grow flex-col text-sm">+ <span className="text-sm font-semibold text-neutral-900">+ {label}+ </span>+ <span className="text-sm font-normal text-neutral-600">+ {description}+ </span>+ </div>+ <CircleCheckFill+ className={cn(+ "-mr-px -mt-px flex size-4 scale-75 items-center justify-center rounded-full opacity-0 transition-[transform,opacity] duration-150",+ isSelected && "scale-100 opacity-100",+ )}+ />+ </label>+ {mostCommon && (+ <span className="py-0.5 text-xs font-medium text-neutral-500">+ Most common+ </span>+ )}+ </div>+ );+ },+ )}+ </div>+ </div>)}<label className="space-y-2"><span className="text-content-emphasis block text-sm font-semibold">- Amount per {defaultRewardType}+ {type === "percentage" ? "Percentage" : "Amount"} per{" "}+ {defaultRewardType}</span><div className="relative rounded-md shadow-sm"><span className="absolute inset-y-0 left-0 flex items-center pl-3 text-sm text-neutral-400">diff --git a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/use-onboarding-program.tsx b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/use-onboarding-program.tsxindex 6aa2b76dcd..ecfcd776ed 100644--- a/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/use-onboarding-program.tsx+++ b/apps/web/app/app.dub.co/(onboarding)/onboarding/(steps)/program/use-onboarding-program.tsx@@ -12,7 +12,7 @@ export function useOnboardingProgram({ domain }: { domain?: string } = {}) {name: name ?? undefined,logo: logo ?? undefined,domain,- maxDuration: 0,+ maxDuration: 12,},},};diff --git a/apps/web/lib/zod/schemas/rewards.ts b/apps/web/lib/zod/schemas/rewards.tsindex 6fe907412e..903f6c763e 100644--- a/apps/web/lib/zod/schemas/rewards.ts+++ b/apps/web/lib/zod/schemas/rewards.ts@@ -3,18 +3,18 @@ import * as z from "zod/v4";import { getPaginationQuerySchema, maxDurationSchema } from "./misc";export const COMMISSION_TYPES = [- {- value: "one-off",- label: "One-off",- description: "Pay a one-time payout",- shortDescription: "Single payouts",- },{value: "recurring",label: "Recurring",description: "Pay an ongoing payout",shortDescription: "Ongoing payouts",},+ {+ value: "one-off",+ label: "One-off",+ description: "Pay a one-time payout",+ shortDescription: "Single payouts",+ },] as const;export type RewardConditionEntityAttribute = {diff --git a/apps/web/ui/partners/rewards/add-edit-reward-sheet.tsx b/apps/web/ui/partners/rewards/add-edit-reward-sheet.tsxindex 36acea3ea1..fa5dc6bcca 100644--- a/apps/web/ui/partners/rewards/add-edit-reward-sheet.tsx+++ b/apps/web/ui/partners/rewards/add-edit-reward-sheet.tsx@@ -26,13 +26,16 @@ import { EventType, RewardStructure } from "@dub/prisma/client";import {Button,Gift,+ Grid,MoneyBills2,Pen2,Sheet,Tooltip,TooltipContent,+ useLocalStorage,useRouterStuff,} from "@dub/ui";+import { CursorRays, InvoiceDollar, UserPlus } from "@dub/ui/icons";import { capitalize, cn, pluralize } from "@dub/utils";import { motion } from "motion/react";import { useAction } from "next-safe-action/hooks";@@ -367,6 +370,7 @@ function RewardSheetContent({</div><div className="flex flex-1 flex-col overflow-y-auto p-6">+ {!reward && <RewardHelperBlock event={event} />}<RewardSheetCardtitle={<div className="w-full">@@ -610,6 +614,87 @@ function RewardSheetContent({);}+const REWARD_HELPER_CONTENT: Record<+ EventType,+ {+ icon: typeof InvoiceDollar;+ title: string;+ description: string;+ }+> = {+ sale: {+ icon: InvoiceDollar,+ title: "Sale rewards",+ description:+ "Reward when revenue is generated. Best for partners, creators, and long term partnerships.",+ },+ lead: {+ icon: UserPlus,+ title: "Lead rewards",+ description:+ "Reward for sign ups or demos. Best for B2B, demos, waitlists, or longer sales cycles.",+ },+ click: {+ icon: CursorRays,+ title: "Click rewards",+ description:+ "Reward for traffic and reach. Best for publishers and trusted partners only.",+ },+};++function RewardHelperBlock({ event }: { event: EventType }) {+ const [dismissed, setDismissed] = useLocalStorage<boolean>(+ `reward-helper-${event}-dismissed`,+ false,+ );++ const content = REWARD_HELPER_CONTENT[event];+ const Icon = content.icon;++ return (+ <motion.div+ animate={+ dismissed+ ? { opacity: 0, height: 0, marginBottom: 0 }+ : { opacity: 1, height: "auto", marginBottom: 16 }+ }+ initial={false}+ className="overflow-hidden"+ inert={dismissed}+ >+ <div className="relative overflow-hidden rounded-xl bg-neutral-100 p-4">+ <div className="absolute right-0 top-0 flex h-full w-1/2 items-start justify-end opacity-30 mix-blend-hard-light blur-[50px] [mask-image:linear-gradient(90deg,transparent,black)] [transform:translateZ(0)]">+ <div className="h-32 w-80 -translate-y-4 translate-x-4 bg-[conic-gradient(from_220deg_at_50%_50%,#FF0000_0%,#EAB308_17%,#1E00FF_31%,#5CFF80_46%,#855AFC_60%,#3A8BFD_78%,#FF0000_100%)]" />+ </div>+ <Grid+ cellSize={60}+ patternOffset={[33, 28]}+ className="inset-[unset] right-0 top-0 h-full w-1/2 text-neutral-300 [mask-image:linear-gradient(90deg,transparent,black)]"+ />++ <div className="relative flex flex-col gap-2">+ <Icon className="size-5 text-neutral-600" />+ <div className="flex flex-col pt-2">+ <span className="text-sm font-medium text-neutral-900">+ {content.title}+ </span>+ <span className="text-sm text-neutral-500">+ {content.description}+ </span>+ </div>+ <Button+ type="button"+ variant="secondary"+ text="Dismiss"+ className="mt-1 h-8 w-fit px-3"+ onClick={() => setDismissed(true)}+ />+ </div>+ </div>+ </motion.div>+ );+}+function RewardSheetCard({title,content,diff --git a/packages/ui/src/button.tsx b/packages/ui/src/button.tsxindex 66b7adfe13..e7e1a90b08 100644--- a/packages/ui/src/button.tsx+++ b/packages/ui/src/button.tsx@@ -13,7 +13,8 @@ export const buttonVariants = cva("transition-all", {"border-border-subtle bg-white dark:bg-black text-content-emphasis hover:bg-bg-muted focus-visible:border-border-emphasis outline-none","data-[state=open]:border-border-emphasis data-[state=open]:ring-4 data-[state=open]:ring-border-subtle",),- outline: "border-transparent text-content-default hover:bg-bg-subtle",+ outline:+ "border-transparent text-content-default hover:bg-neutral-900/5",success:"border-blue-500 bg-blue-500 text-white hover:bg-blue-600 hover:ring-4 hover:ring-blue-100",danger: