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.

finalize changes

Steven Tey1ef0b702f492
diff --git a/apps/web/lib/actions/partners/create-manual-commission.ts b/apps/web/lib/actions/partners/create-manual-commission.ts
index 98fa371539..7888867bdc 100644
--- a/apps/web/lib/actions/partners/create-manual-commission.ts
+++ b/apps/web/lib/actions/partners/create-manual-commission.ts
@@ -156,6 +156,12 @@ export const createManualCommissionAction = authActionClient
// If we're using existing events (Stripe invoice for sale)
if (useExistingEvents) {
+ if (commissionType !== "sale") {
+ throw new Error(
+ "You can only use existing events for recurring sale commissions.",
+ );
+ }
+
if (!workspace.stripeConnectId) {
throw new Error(
"Your workspace isn't connected to Stripe yet. Please install the Stripe integration under /settings/integrations/stripe to proceed.",
@@ -186,6 +192,7 @@ export const createManualCommissionAction = authActionClient
);
}
+ // use the first ever stripe invoice created date as the last lead and conversion dates
lastLeadAt = stripeCustomerInvoices[0].createdAt;
lastConversionAt = stripeCustomerInvoices[0].createdAt;
diff --git a/apps/web/lib/auth/options.ts b/apps/web/lib/auth/options.ts
index 9709d584fa..f1a45ea06c 100644
--- a/apps/web/lib/auth/options.ts
+++ b/apps/web/lib/auth/options.ts
@@ -532,8 +532,8 @@ export const authOptions: NextAuthOptions = {
email: true,
image: true,
isMachine: true,
- defaultPartnerId: true,
defaultWorkspace: true,
+ defaultPartnerId: true,
},
});
diff --git a/apps/web/lib/auth/partner.ts b/apps/web/lib/auth/partner.ts
index c61de781ee..f8a5b5d9aa 100644
--- a/apps/web/lib/auth/partner.ts
+++ b/apps/web/lib/auth/partner.ts
@@ -60,6 +60,7 @@ export const withPartnerProfile = (
{ params: initialParams }: { params: Promise<Record<string, string>> },
) => {
const params = (await initialParams) || {};
+ const searchParams = getSearchParams(req.url);
let apiKey: string | undefined;
let requestHeaders = await headers();
@@ -100,7 +101,9 @@ export const withPartnerProfile = (
id: true,
name: true,
email: true,
+ image: true,
isMachine: true,
+ defaultWorkspace: true,
defaultPartnerId: true,
},
},
@@ -177,9 +180,7 @@ export const withPartnerProfile = (
}
}
- const searchParams = getSearchParams(req.url);
const { defaultPartnerId, id: userId } = session.user;
-
if (!defaultPartnerId) {
throw new DubApiError({
code: "not_found",
diff --git a/apps/web/lib/auth/workspace.ts b/apps/web/lib/auth/workspace.ts
index 5e3894d15b..74b42d0f76 100644
--- a/apps/web/lib/auth/workspace.ts
+++ b/apps/web/lib/auth/workspace.ts
@@ -199,7 +199,10 @@ export const withWorkspace = (
id: true,
name: true,
email: true,
+ image: true,
isMachine: true,
+ defaultWorkspace: true,
+ defaultPartnerId: true,
},
},
},