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.

Event entities/logic

Tim Wilson377518b40d52
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 9caf79e4c9..a8588cd9f4 100644
--- a/apps/web/ui/partners/rewards/add-edit-reward-sheet.tsx
+++ b/apps/web/ui/partners/rewards/add-edit-reward-sheet.tsx
@@ -361,7 +361,11 @@ function RewardSheetContent({
</span>
</>
}
- content={<RewardsLogic isDefaultReward={!!isDefault} />}
+ content={
+ selectedEvent === "click" ? undefined : (
+ <RewardsLogic isDefaultReward={!!isDefault} />
+ )
+ }
/>
<VerticalLine />
diff --git a/apps/web/ui/partners/rewards/rewards-logic.tsx b/apps/web/ui/partners/rewards/rewards-logic.tsx
index 96bc4971f5..081900c4df 100644
--- a/apps/web/ui/partners/rewards/rewards-logic.tsx
+++ b/apps/web/ui/partners/rewards/rewards-logic.tsx
@@ -10,6 +10,7 @@ import {
CONDITION_SALE_ATTRIBUTES,
} from "@/lib/zod/schemas/rewards";
import { X } from "@/ui/shared/icons";
+import { EventType } from "@dub/prisma/client";
import {
ArrowTurnRight2,
Button,
@@ -183,6 +184,12 @@ const ENTITIES = {
},
} as const;
+const EVENT_ENTITIES: Record<EventType, (keyof typeof ENTITIES)[]> = {
+ sale: ["sale", "customer"],
+ lead: ["customer"],
+ click: [],
+};
+
const ATTRIBUTE_LABELS = {
productId: "Product ID",
};
@@ -228,9 +235,9 @@ function ConditionLogic({
const conditionKey = `${modifierKey}.conditions.${conditionIndex}` as const;
const { control, setValue, register } = useAddEditRewardForm();
- const [condition, operator] = useWatch({
+ const [event, condition, operator] = useWatch({
control,
- name: [conditionKey, `${modifierKey}.operator`],
+ name: ["event", conditionKey, `${modifierKey}.operator`],
});
const icon = condition.entity
@@ -260,10 +267,14 @@ function ConditionLogic({
},
)
}
- items={Object.keys(ENTITIES).map((entity) => ({
- text: capitalize(entity) || entity,
- value: entity,
- }))}
+ items={Object.keys(ENTITIES)
+ .filter((e) =>
+ EVENT_ENTITIES[event]?.includes(e as keyof typeof ENTITIES),
+ )
+ .map((entity) => ({
+ text: capitalize(entity) || entity,
+ value: entity,
+ }))}
/>
</InlineBadgePopover>{" "}
{condition.entity && (