The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Add manual confirmation step before approving performance bounties
Kiran K1f4544607ed2
diff --git a/apps/web/lib/actions/partners/approve-bounty-submission.ts b/apps/web/lib/actions/partners/approve-bounty-submission.tsindex 961a21f0fe..1891c6ab25 100644--- a/apps/web/lib/actions/partners/approve-bounty-submission.ts+++ b/apps/web/lib/actions/partners/approve-bounty-submission.ts@@ -52,10 +52,6 @@ export const approveBountySubmissionAction = authActionClientthrow new Error("Bounty submission already approved.");}- if (bounty.type === "performance") {- throw new Error("Performance based bounties cannot be approved.");- }-// Find the reward amountconst finalRewardAmount = bounty.rewardAmount ?? rewardAmount;diff --git a/apps/web/lib/api/workflows/execute-award-bounty-workflow.ts b/apps/web/lib/api/workflows/execute-award-bounty-workflow.tsindex dfc191859f..301e773228 100644--- a/apps/web/lib/api/workflows/execute-award-bounty-workflow.ts+++ b/apps/web/lib/api/workflows/execute-award-bounty-workflow.ts@@ -1,4 +1,3 @@-import { createPartnerCommission } from "@/lib/partners/create-partner-commission";import { WorkflowConditionAttribute, WorkflowContext } from "@/lib/types";import { WORKFLOW_ACTION_TYPES } from "@/lib/zod/schemas/workflows";import { sendEmail } from "@dub/email";@@ -88,12 +87,16 @@ export const executeAwardBountyWorkflow = async ({}}- // Check if the partner's submission has already been approved- if (submissions.length > 0 && submissions[0].status === "approved") {- console.log(- `Partner ${partnerId} has already been awarded this bounty (bountyId: ${bounty.id}, submissionId: ${submissions[0].id}).`,- );- return;+ if (submissions.length > 0) {+ const submission = submissions[0];++ if (submission.status === "submitted" || submission.status === "approved") {+ console.log(+ `Partner ${partnerId} has already ${submission.status === "submitted" ? "finished" : "been awarded"} this bounty (bountyId: ${bounty.id}, submissionId: ${submissions[0].id}).`,+ );++ return;+ }}console.log(@@ -157,32 +160,14 @@ export const executeAwardBountyWorkflow = async ({return;}- // Create the commission for the partner- const { commission } = await createPartnerCommission({- event: "custom",- partnerId,- programId: bounty.programId,- amount: bounty.rewardAmount,- quantity: 1,- description: `Commission for successfully completed "${bounty.name}" bounty.`,- skipWorkflow: true,- });-- if (!commission) {- console.error(- `Failed to create commission for partner ${partnerId} in program ${bounty.programId} for bounty ${bounty.id}.`,- );- return;- }-- // Update the bounty submission+ // Mark the bounty as submittedconst { partner } = await prisma.bountySubmission.update({where: {id: bountySubmission.id,+ status: "draft",},data: {- commissionId: commission.id,- status: "approved",+ status: "submitted",},include: {partner: true,diff --git a/packages/email/src/templates/bounty-completed.tsx b/packages/email/src/templates/bounty-completed.tsxindex 4cd8dd8765..1e665d811e 100644--- a/packages/email/src/templates/bounty-completed.tsx+++ b/packages/email/src/templates/bounty-completed.tsx@@ -60,18 +60,10 @@ export default function BountyCompleted({<BountyThumbnailImage type={bounty.type} /></Section>- {bounty.type === "submission" ? (- <Text className="text-sm leading-5 text-neutral-600">- Once <strong>{program.name}</strong> has confirmed your bounty,- you will receive an email with the commission details.- </Text>- ) : (- <Text className="text-sm leading-5 text-neutral-600">- The commission from the bounty has been added to your upcoming- payout, and will be sent to your bank account when{" "}- <strong>{program.name}</strong> processes their next payout.- </Text>- )}+ <Text className="text-sm leading-5 text-neutral-600">+ Once <strong>{program.name}</strong> has confirmed your bounty,+ you will receive an email with the commission details.+ </Text><Text className="text-sm leading-5 text-neutral-600">If you have any questions, please don't hesitate to{" "}