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.

changeDescription → activityDescription

Steven Tey52d2efe1c47d
diff --git a/apps/web/lib/actions/partners/create-reward.ts b/apps/web/lib/actions/partners/create-reward.ts
index f797f6e4c5..948315c6c1 100644
--- a/apps/web/lib/actions/partners/create-reward.ts
+++ b/apps/web/lib/actions/partners/create-reward.ts
@@ -37,7 +37,7 @@ export const createRewardAction = authActionClient
groupId,
spendLimitAmount,
spendLimitInterval,
- changeDescription,
+ activityDescription,
} = parsedInput;
throwIfNoPermission({
@@ -133,7 +133,7 @@ export const createRewardAction = authActionClient
description: formatRewardDescription(serializeReward(reward), {
includeEarnPrefix: false,
}),
- changeDescription,
+ activityDescription,
},
});
@@ -163,7 +163,7 @@ export const createRewardAction = authActionClient
parentResourceId: groupId,
old: null,
new: reward,
- description: changeDescription,
+ description: activityDescription,
}),
]),
);
diff --git a/apps/web/lib/actions/partners/delete-reward.ts b/apps/web/lib/actions/partners/delete-reward.ts
index 511bd4c85b..20d05018b1 100644
--- a/apps/web/lib/actions/partners/delete-reward.ts
+++ b/apps/web/lib/actions/partners/delete-reward.ts
@@ -9,7 +9,7 @@ import { queueRewardProcessing } from "@/lib/api/rewards/queue-reward-processing
import { prisma } from "@/lib/prisma";
import {
REWARD_EVENT_COLUMN_MAPPING,
- rewardChangeDescriptionSchema,
+ rewardActivityDescriptionSchema,
} from "@/lib/zod/schemas/rewards";
import { formatRewardDescription } from "@/ui/partners/format-reward-description";
import { waitUntil } from "@vercel/functions";
@@ -22,13 +22,13 @@ const deleteRewardSchema = z
workspaceId: z.string(),
rewardId: z.string(),
})
- .extend(rewardChangeDescriptionSchema.shape);
+ .extend(rewardActivityDescriptionSchema.shape);
export const deleteRewardAction = authActionClient
.inputSchema(deleteRewardSchema)
.action(async ({ parsedInput, ctx }) => {
const { workspace, user } = ctx;
- const { rewardId, changeDescription } = parsedInput;
+ const { rewardId, activityDescription } = parsedInput;
throwIfNoPermission({
role: workspace.role,
@@ -83,7 +83,7 @@ export const deleteRewardAction = authActionClient
description: formatRewardDescription(serializeReward(deletedReward), {
includeEarnPrefix: false,
}),
- changeDescription,
+ activityDescription,
},
});
@@ -113,7 +113,7 @@ export const deleteRewardAction = authActionClient
parentResourceId: partnerGroup.id,
old: reward,
new: null,
- description: changeDescription,
+ description: activityDescription,
}),
]),
);
diff --git a/apps/web/lib/actions/partners/update-reward.ts b/apps/web/lib/actions/partners/update-reward.ts
index 09f64184f5..8895586684 100644
--- a/apps/web/lib/actions/partners/update-reward.ts
+++ b/apps/web/lib/actions/partners/update-reward.ts
@@ -33,7 +33,7 @@ export const updateRewardAction = authActionClient
rewardId,
spendLimitAmount,
spendLimitInterval,
- changeDescription,
+ activityDescription,
} = parsedInput;
throwIfNoPermission({
@@ -146,7 +146,7 @@ export const updateRewardAction = authActionClient
description: formatRewardDescription(serializeReward(updatedReward), {
includeEarnPrefix: false,
}),
- changeDescription,
+ activityDescription,
},
});
@@ -176,7 +176,7 @@ export const updateRewardAction = authActionClient
parentResourceId: partnerGroup.id,
old: reward,
new: updatedReward,
- description: changeDescription,
+ description: activityDescription,
}),
// we only cache default group pages for now so we need to invalidate them
diff --git a/apps/web/lib/api/partners/notify-partner-reward-change.ts b/apps/web/lib/api/partners/notify-partner-reward-change.ts
index 57bf23b11c..d8c1e5ae4f 100644
--- a/apps/web/lib/api/partners/notify-partner-reward-change.ts
+++ b/apps/web/lib/api/partners/notify-partner-reward-change.ts
@@ -15,7 +15,7 @@ interface NotifyPartnerRewardChangeParams {
action: RewardJob["event"];
program: Pick<Program, "id" | "name" | "logo" | "slug" | "supportEmail">;
reward: Pick<Reward, "id" | "event">;
- rewardSnapshot: { description: string; changeDescription?: string };
+ rewardSnapshot: { description: string; activityDescription?: string };
effectiveAt: Date | string;
users: Pick<User, "name" | "email">[];
idempotencyKey: string;
@@ -59,7 +59,7 @@ export async function notifyPartnerRewardChange({
rewardSnapshot: {
description: rewardSnapshot.description,
icon: REWARD_ICONS[reward.event],
- changeDescription: rewardSnapshot.changeDescription,
+ activityDescription: rewardSnapshot.activityDescription,
},
effectiveAt,
action,
diff --git a/apps/web/lib/api/rewards/queue-reward-processing.ts b/apps/web/lib/api/rewards/queue-reward-processing.ts
index 15495d19ab..943bab557e 100644
--- a/apps/web/lib/api/rewards/queue-reward-processing.ts
+++ b/apps/web/lib/api/rewards/queue-reward-processing.ts
@@ -26,7 +26,7 @@ export const rewardJobSchema = z.object({
id: z.string(),
event: z.enum(EventType),
description: z.string(),
- changeDescription: z.string().optional(),
+ activityDescription: z.string().optional(),
}),
});
diff --git a/apps/web/lib/zod/schemas/rewards.ts b/apps/web/lib/zod/schemas/rewards.ts
index 94859b0bac..97d069493c 100644
--- a/apps/web/lib/zod/schemas/rewards.ts
+++ b/apps/web/lib/zod/schemas/rewards.ts
@@ -434,8 +434,8 @@ export const REWARD_DESCRIPTION_MAX_LENGTH = 100;
export const REWARD_TOOLTIP_DESCRIPTION_MAX_LENGTH = 2000;
export const REWARD_CHANGE_DESCRIPTION_MAX_LENGTH = 240;
-export const rewardChangeDescriptionSchema = z.object({
- changeDescription: z
+export const rewardActivityDescriptionSchema = z.object({
+ activityDescription: z
.string()
.max(REWARD_CHANGE_DESCRIPTION_MAX_LENGTH)
.optional()
@@ -479,16 +479,17 @@ export const createOrUpdateRewardSchema = z.object({
.nullish(),
groupId: z.string(),
...rewardSpendLimitSchema.shape,
+ ...rewardActivityDescriptionSchema.shape,
});
-export const createRewardSchema = createOrUpdateRewardSchema
- .extend(rewardChangeDescriptionSchema.shape)
- .superRefine((data) => {
+export const createRewardSchema = createOrUpdateRewardSchema.superRefine(
+ (data) => {
if (data.event === EventType.click || data.event === EventType.lead) {
data.maxDuration = 0;
data.type = "flat";
}
- });
+ },
+);
export const updateRewardSchema = createOrUpdateRewardSchema
.omit({
@@ -497,7 +498,6 @@ export const updateRewardSchema = createOrUpdateRewardSchema
})
.extend({
rewardId: z.string(),
- ...rewardChangeDescriptionSchema.shape,
});
export const rewardPartnersQuerySchema = z
diff --git a/apps/web/ui/modals/confirm-reward-change-modal.tsx b/apps/web/ui/modals/confirm-reward-change-modal.tsx
index 14c549d471..6cf35011eb 100644
--- a/apps/web/ui/modals/confirm-reward-change-modal.tsx
+++ b/apps/web/ui/modals/confirm-reward-change-modal.tsx
@@ -27,7 +27,7 @@ const CONFIRM_TEXT: Record<RewardChangeAction, string> = {
};
type ConfirmRewardChangeFormData = {
- changeDescription: string;
+ activityDescription: string;
};
type ConfirmRewardChangeModalProps = {
@@ -50,7 +50,7 @@ type ConfirmRewardChangeModalProps = {
| "spendLimitInterval"
>;
partnerCount?: number;
- onConfirm: (changeDescription?: string) => Promise<void>;
+ onConfirm: (activityDescription?: string) => Promise<void>;
isPending?: boolean;
};
@@ -75,13 +75,13 @@ export function ConfirmRewardChangeModal({
formState: { errors },
} = useForm<ConfirmRewardChangeFormData>({
defaultValues: {
- changeDescription: "",
+ activityDescription: "",
},
});
useEffect(() => {
if (showModal) {
- reset({ changeDescription: "" });
+ reset({ activityDescription: "" });
}
}, [showModal, reset]);
@@ -91,10 +91,10 @@ export function ConfirmRewardChangeModal({
deleted: "removed from",
}[action];
- const onSubmit = handleSubmit(async ({ changeDescription }) => {
+ const onSubmit = handleSubmit(async ({ activityDescription }) => {
setIsLoading(true);
try {
- const trimmedDescription = changeDescription.trim();
+ const trimmedDescription = activityDescription.trim();
await onConfirm(trimmedDescription || undefined);
setShowModal(false);
} finally {
@@ -143,7 +143,7 @@ export function ConfirmRewardChangeModal({
<div className="mt-4">
<div className="flex items-center justify-between">
<label
- htmlFor="changeDescription"
+ htmlFor="activityDescription"
className="text-content-emphasis text-sm font-medium"
>
Message to partners
@@ -152,39 +152,30 @@ export function ConfirmRewardChangeModal({
</span>
</label>
<MaxCharactersCounter
- name="changeDescription"
+ name="activityDescription"
maxLength={REWARD_CHANGE_DESCRIPTION_MAX_LENGTH}
control={control}
/>
</div>
<textarea
- id="changeDescription"
+ id="activityDescription"
rows={3}
maxLength={REWARD_CHANGE_DESCRIPTION_MAX_LENGTH}
placeholder="Add context about this change..."
className={cn(
"mt-2 block w-full rounded-md border-neutral-300 text-sm text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500",
- errors.changeDescription && "border-red-600",
+ errors.activityDescription && "border-red-600",
)}
- {...register("changeDescription", {
+ {...register("activityDescription", {
maxLength: {
value: REWARD_CHANGE_DESCRIPTION_MAX_LENGTH,
message: `Must be ${REWARD_CHANGE_DESCRIPTION_MAX_LENGTH} characters or fewer`,
},
})}
/>
- {errors.changeDescription && (
+ {errors.activityDescription && (
<p className="mt-1 text-xs text-red-600">
- {errors.changeDescription.message}
- </p>
- )}
- {partnerCount && partnerCount > 0 ? (
- <p className="mt-1.5 text-xs text-neutral-500">
- Included in the partner notification email and activity log
- </p>
- ) : (
- <p className="mt-1.5 text-xs text-neutral-500">
- Saved to the activity log
+ {errors.activityDescription.message}
</p>
)}
</div>
@@ -217,7 +208,7 @@ export function useConfirmRewardChangeModal() {
action: RewardChangeAction;
event: EventType;
reward: ConfirmRewardChangeModalProps["reward"];
- onConfirm: (changeDescription?: string) => Promise<void>;
+ onConfirm: (activityDescription?: string) => Promise<void>;
isPending?: boolean;
partnerCount?: number;
} | null>(null);
@@ -228,7 +219,7 @@ export function useConfirmRewardChangeModal() {
event: EventType;
reward: ConfirmRewardChangeModalProps["reward"];
partnerCount?: number;
- onConfirm: (changeDescription?: string) => Promise<void>;
+ onConfirm: (activityDescription?: string) => Promise<void>;
isPending?: boolean;
}) => setState(options),
closeConfirmRewardChangeModal: () => setState(null),
diff --git a/apps/web/ui/partners/rewards/add-edit-reward-sheet.tsx b/apps/web/ui/partners/rewards/add-edit-reward-sheet.tsx
index a4933ce1af..13d907282f 100644
--- a/apps/web/ui/partners/rewards/add-edit-reward-sheet.tsx
+++ b/apps/web/ui/partners/rewards/add-edit-reward-sheet.tsx
@@ -418,18 +418,18 @@ function RewardSheetContent({
reward: payload!,
partnerCount: partnerCountForConfirm,
isPending: isCreating || isUpdating,
- onConfirm: async (changeDescription) => {
+ onConfirm: async (activityDescription) => {
if (!reward) {
await createReward({
...payload!,
groupId: group.id,
- changeDescription,
+ activityDescription,
});
} else {
await updateReward({
...payload!,
rewardId: reward.id,
- changeDescription,
+ activityDescription,
});
}
},
@@ -447,11 +447,11 @@ function RewardSheetContent({
reward,
partnerCount: partnerCountForConfirm,
isPending: isDeleting,
- onConfirm: async (changeDescription) => {
+ onConfirm: async (activityDescription) => {
await deleteReward({
workspaceId,
rewardId: reward.id,
- changeDescription,
+ activityDescription,
});
},
});
diff --git a/packages/email/src/templates/partner-reward-updated.tsx b/packages/email/src/templates/partner-reward-updated.tsx
index ca9634d297..8c0c2e4a85 100644
--- a/packages/email/src/templates/partner-reward-updated.tsx
+++ b/packages/email/src/templates/partner-reward-updated.tsx
@@ -37,7 +37,8 @@ export default function PartnerRewardUpdated({
rewardSnapshot = {
description: "30% per sale for the customers lifetime",
icon: "https://assets.dub.co/email-assets/icons/invoice-dollar.png",
- changeDescription: "We're increasing rewards to better align with market rates.",
+ activityDescription:
+ "We're increasing rewards to better align with market rates.",
},
effectiveAt = new Date("2026-01-02T20:32:00.000Z"),
action = "reward-created",
@@ -55,7 +56,7 @@ export default function PartnerRewardUpdated({
rewardSnapshot: {
description: string;
icon: string;
- changeDescription?: string;
+ activityDescription?: string;
};
effectiveAt: Date | string;
action: "reward-created" | "reward-updated" | "reward-deleted";
@@ -110,10 +111,10 @@ export default function PartnerRewardUpdated({
</Section>
</Section>
- {rewardSnapshot.changeDescription && (
+ {rewardSnapshot.activityDescription && (
<Text className="mb-0 mt-0 text-sm leading-6 text-neutral-600">
<strong>Message from {program.name}:</strong>{" "}
- {rewardSnapshot.changeDescription}
+ {rewardSnapshot.activityDescription}
</Text>
)}