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.

Update create-commission-sheet.tsx

Kiran Kea3041ffa8bb
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/create-commission-sheet.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/create-commission-sheet.tsx
index 6666ba3ef4..274e39644a 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/create-commission-sheet.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/create-commission-sheet.tsx
@@ -174,12 +174,14 @@ function CreateCommissionSheetContent({
? new Date(data.leadEventDate).toISOString()
: null;
- // Get selected event IDs (exclude the excluded ones)
- const selectedEventIds = existingEvents
- .filter(
- (event) => event.eventId && !excludedEventIds.includes(event.eventId),
- )
- .map((event) => event.eventId!);
+ // Get selected event IDs only if using existing events
+ const selectedEventIds = useExistingEvents
+ ? existingEvents
+ .filter(
+ (event) => event.eventId && !excludedEventIds.includes(event.eventId),
+ )
+ .map((event) => event.eventId!)
+ : [];
await executeAsync({
...data,
@@ -222,6 +224,11 @@ function CreateCommissionSheetContent({
setExcludedEventIds([]);
}, [customerId]);
+ // Reset excluded events when switching between existing events and create from scratch
+ useEffect(() => {
+ setExcludedEventIds([]);
+ }, [useExistingEvents]);
+
// fetch existing events for given customer (filtered by commissionType)
useEffect(() => {
if (