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 calculations

Steven Teyc87bda889b7c
diff --git a/apps/web/app/api/stripe/integration/webhook/invoice-paid.ts b/apps/web/app/api/stripe/integration/webhook/invoice-paid.ts
index f7958478cc..0d4d554ac4 100644
--- a/apps/web/app/api/stripe/integration/webhook/invoice-paid.ts
+++ b/apps/web/app/api/stripe/integration/webhook/invoice-paid.ts
@@ -139,17 +139,19 @@ export async function invoicePaid(event: Stripe.Event) {
},
});
- if (reward.maxDuration === 0 && firstCommission) {
- eligibleForCommission = false;
- } else if (firstCommission) {
- // Calculate months difference between first commission and now
- const monthsDifference = differenceInMonths(
- new Date(),
- firstCommission.createdAt,
- );
-
- if (monthsDifference >= reward.maxDuration) {
+ if (firstCommission) {
+ if (reward.maxDuration === 0) {
eligibleForCommission = false;
+ } else {
+ // Calculate months difference between first commission and now
+ const monthsDifference = differenceInMonths(
+ new Date(),
+ firstCommission.createdAt,
+ );
+
+ if (monthsDifference >= reward.maxDuration) {
+ eligibleForCommission = false;
+ }
}
}
}
diff --git a/apps/web/app/api/track/sale/route.ts b/apps/web/app/api/track/sale/route.ts
index 35cbb8fc91..73a1958ff1 100644
--- a/apps/web/app/api/track/sale/route.ts
+++ b/apps/web/app/api/track/sale/route.ts
@@ -199,17 +199,19 @@ export const POST = withWorkspace(
},
});
- if (reward.maxDuration === 0 && firstCommission) {
- eligibleForCommission = false;
- } else if (firstCommission) {
- // Calculate months difference between first commission and now
- const monthsDifference = differenceInMonths(
- new Date(),
- firstCommission.createdAt,
- );
-
- if (monthsDifference >= reward.maxDuration) {
+ if (firstCommission) {
+ if (reward.maxDuration === 0) {
eligibleForCommission = false;
+ } else {
+ // Calculate months difference between first commission and now
+ const monthsDifference = differenceInMonths(
+ new Date(),
+ firstCommission.createdAt,
+ );
+
+ if (monthsDifference >= reward.maxDuration) {
+ eligibleForCommission = false;
+ }
}
}
}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/pending-payouts.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/pending-payouts.tsx
index 9a23e2f099..295eb19240 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/pending-payouts.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/pending-payouts.tsx
@@ -4,7 +4,6 @@ import { usePayoutDetailsSheet } from "@/ui/partners/payout-details-sheet";
import { buttonVariants } from "@dub/ui";
import {
cn,
- COUNTRIES,
currencyFormatter,
DICEBEAR_AVATAR_URL,
fetcher,
@@ -113,7 +112,7 @@ function PayoutRow({ payout }: { payout: PayoutResponse }) {
<div className="flex flex-col">
<span className="text-neutral-800">{payout.partner.name}</span>
<span className="text-neutral-500">
- {COUNTRIES[payout.partner.country ?? ""] ?? "-"}
+ {payout.partner.email ?? "-"}
</span>
</div>
</div>
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/top-partners.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/top-partners.tsx
index 90d7e63506..66e016e3cd 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/top-partners.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/top-partners.tsx
@@ -3,7 +3,6 @@ import { EnrolledPartnerProps } from "@/lib/types";
import { buttonVariants } from "@dub/ui";
import {
cn,
- COUNTRIES,
currencyFormatter,
DICEBEAR_AVATAR_URL,
fetcher,
@@ -78,7 +77,7 @@ export function TopPartners() {
<div className="flex flex-col">
<span className="text-neutral-800">{partner.name}</span>
<span className="text-neutral-500">
- {COUNTRIES[partner.country ?? ""] ?? "-"}
+ {partner.email ?? "-"}
</span>
</div>
</div>