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 route.ts

Kiran Kd0ad3d2fdb55
diff --git a/apps/web/app/(ee)/api/bounties/[bountyId]/route.ts b/apps/web/app/(ee)/api/bounties/[bountyId]/route.ts
index 01b032f7bf..d753680a6e 100644
--- a/apps/web/app/(ee)/api/bounties/[bountyId]/route.ts
+++ b/apps/web/app/(ee)/api/bounties/[bountyId]/route.ts
@@ -77,16 +77,32 @@ export const DELETE = withWorkspace(async ({ workspace, params }) => {
const { bountyId } = params;
const programId = getDefaultProgramIdOrThrow(workspace);
- const bounty = await getBountyOrThrow({
+ await getBountyOrThrow({
bountyId,
programId,
});
- await prisma.bounty.delete({
- where: {
- id: bounty.id,
- },
+ await prisma.$transaction(async (tx) => {
+ const bounty = await tx.bounty.delete({
+ where: {
+ id: bountyId,
+ },
+ });
+
+ await tx.bountySubmission.deleteMany({
+ where: {
+ bountyId,
+ },
+ });
+
+ if (bounty.workflowId) {
+ await tx.workflow.delete({
+ where: {
+ id: bounty.workflowId,
+ },
+ });
+ }
});
- return NextResponse.json({ id: bounty.id });
+ return NextResponse.json({ id: bountyId });
});