The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fix commission update action
Steven Tey03b8b78393cb
diff --git a/apps/web/app/(ee)/api/cron/payouts/process/process-payouts.ts b/apps/web/app/(ee)/api/cron/payouts/process/process-payouts.tsindex 00c591cfb6..b6aa5480b6 100644--- a/apps/web/app/(ee)/api/cron/payouts/process/process-payouts.ts+++ b/apps/web/app/(ee)/api/cron/payouts/process/process-payouts.ts@@ -287,7 +287,15 @@ export async function processPayouts({console.error("Error sending message to Qstash", qstashResponse);}- const userWhoInitiatedPayout = users[0]?.user;+ // should never happen, but just in case+ if (users.length === 0) {+ console.error(+ `No users found for workspace ${workspace.id}. Skipping email send...`,+ );+ return;+ }++ const userWhoInitiatedPayout = users[0].user;if (userWhoInitiatedPayout.email) {const emailRes = await sendEmail({to: userWhoInitiatedPayout.email,diff --git a/apps/web/lib/actions/partners/mark-commission-fraud-or-canceled.ts b/apps/web/lib/actions/partners/mark-commission-fraud-or-canceled.tsindex 15ba2b0af9..30bcef0a86 100644--- a/apps/web/lib/actions/partners/mark-commission-fraud-or-canceled.ts+++ b/apps/web/lib/actions/partners/mark-commission-fraud-or-canceled.ts@@ -33,17 +33,13 @@ export const markCommissionFraudOrCanceledAction = authActionClientthrow new Error("Commission not found.");}- if (commission.type === "custom") {- throw new Error(- "You cannot mark a custom commission as fraud or canceled.",- );- }-const { partnerId, customerId } = commission;- // Find all historical commissions for this customer+ // for custom commissions, only update this commission+ // for all other commission types, update all historical commissions for the customer and partner combinationconst commissions = await prisma.commission.findMany({where: {+ ...(commission.type === "custom" ? { id: commissionId } : {}),partnerId,customerId,status: {diff --git a/apps/web/ui/partners/mark-commission-fraud-or-canceled-modal.tsx b/apps/web/ui/partners/mark-commission-fraud-or-canceled-modal.tsxindex 7a242bf814..098bc92478 100644--- a/apps/web/ui/partners/mark-commission-fraud-or-canceled-modal.tsx+++ b/apps/web/ui/partners/mark-commission-fraud-or-canceled-modal.tsx@@ -114,10 +114,12 @@ function ModalInner({<div className="flex flex-col space-y-6 bg-neutral-50 p-6"><div className="rounded-lg border border-red-200 bg-red-50 p-4"><div className="text-sm text-red-900">- <span className="font-bold">Warning:</span> This will mark all- future and past commissions for this customer and partner- combination as {status}. This action cannot be undone – please- proceed with caution.+ <span className="font-bold">Warning:</span> This will mark{" "}+ {commission.type === "custom"+ ? "this commission"+ : "all future and past commissions for this customer and partner combination"}{" "}+ as {status}. This action cannot be undone – please proceed with+ caution.</div></div>