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.

Add bounty submissions API and related schemas

Kiran K36e59ac118ea
diff --git a/apps/web/app/(ee)/api/bounties/[bountyId]/submissions/route.ts b/apps/web/app/(ee)/api/bounties/[bountyId]/submissions/route.ts
new file mode 100644
index 0000000000..685b08f57b
--- /dev/null
+++ b/apps/web/app/(ee)/api/bounties/[bountyId]/submissions/route.ts
@@ -0,0 +1,33 @@
+import { getBountyOrThrow } from "@/lib/api/bounty/get-bounty-or-throw";
+import { getDefaultProgramIdOrThrow } from "@/lib/api/programs/get-default-program-id-or-throw";
+import { withWorkspace } from "@/lib/auth";
+import { BountySubmissionSchema } from "@/lib/zod/schemas/bounties";
+import { prisma } from "@dub/prisma";
+import { NextResponse } from "next/server";
+
+// TODO:
+// Add filter, pagination
+
+// GET /api/bounties/[bountyId]/submissions - get all submissions for a bounty
+export const GET = withWorkspace(async ({ workspace, params }) => {
+ const { bountyId } = params;
+ const programId = getDefaultProgramIdOrThrow(workspace);
+
+ await getBountyOrThrow({
+ bountyId,
+ programId,
+ });
+
+ const submissions = await prisma.bountySubmission.findMany({
+ where: {
+ bountyId,
+ },
+ include: {
+ user: true,
+ partner: true,
+ commission: true,
+ },
+ });
+
+ return NextResponse.json(BountySubmissionSchema.parse(submissions));
+});
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/page.tsx
new file mode 100644
index 0000000000..b3ce4db7f7
--- /dev/null
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/page.tsx
@@ -0,0 +1,28 @@
+import { PageContent } from "@/ui/layout/page-content";
+import { PageWidthWrapper } from "@/ui/layout/page-width-wrapper";
+import { ChevronRight } from "@dub/ui";
+import { Trophy } from "lucide-react";
+
+export default function Page() {
+ return (
+ <PageContent
+ title={
+ <div className="flex items-center gap-1">
+ <div className="flex items-center justify-center rounded-lg bg-neutral-100 p-2">
+ <Trophy className="size-4" />
+ </div>
+ <div className="flex items-center gap-1.5">
+ <ChevronRight className="text-content-subtle size-2.5 shrink-0 [&_*]:stroke-2" />
+ <span className="text-lg font-semibold leading-7 text-neutral-900">
+ Bounty details
+ </span>
+ </div>
+ </div>
+ }
+ >
+ <PageWidthWrapper>
+ <></>
+ </PageWidthWrapper>
+ </PageContent>
+ );
+}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/bounty-card.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/bounty-card.tsx
index a08eaf755f..594066cd86 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/bounty-card.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/bounty-card.tsx
@@ -13,9 +13,9 @@ export function BountyCard({ bounty }: { bounty: BountyProps }) {
return (
<ProgramOverviewCard className="cursor-pointer p-5 transition-shadow hover:shadow-lg">
<div className="flex flex-col gap-5">
- <div className="flex items-center justify-center rounded-lg bg-neutral-50 px-32 py-4">
+ <div className="flex h-[132px] items-center justify-center rounded-lg bg-neutral-100 px-32 py-4">
<div className="relative">
- <Trophy className="size-14" />
+ <Trophy className="size-20" />
</div>
</div>
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/page.tsx
index bb457946e4..79b1ef9ccd 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/page.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/page.tsx
@@ -1,11 +1,9 @@
-"use client";
-
import { PageContent } from "@/ui/layout/page-content";
import { PageWidthWrapper } from "@/ui/layout/page-width-wrapper";
import { BountyList } from "./bounty-list";
import { CreateBountyButton } from "./create-bounty-button";
-export default function ProgramCommissions() {
+export default function Page() {
return (
<PageContent
title="Bounties"
diff --git a/apps/web/lib/zod/schemas/bounties.ts b/apps/web/lib/zod/schemas/bounties.ts
index 1ee06686aa..775266aa75 100644
--- a/apps/web/lib/zod/schemas/bounties.ts
+++ b/apps/web/lib/zod/schemas/bounties.ts
@@ -1,5 +1,8 @@
-import { BountyType } from "@dub/prisma/client";
+import { BountySubmissionStatus, BountyType } from "@dub/prisma/client";
import { z } from "zod";
+import { CommissionSchema } from "./commissions";
+import { PartnerSchema } from "./partners";
+import { UserSchema } from "./users";
import { parseDateSchema } from "./utils";
export const SUBMISSION_REQUIREMENTS = ["image", "url"] as const;
@@ -35,3 +38,34 @@ export const BountySchema = z.object({
endsAt: z.date().nullable(),
rewardAmount: z.number(),
});
+
+export const BountySubmissionSchema = z.object({
+ id: z.string(),
+ description: z.string().nullable(),
+ status: z.nativeEnum(BountySubmissionStatus),
+ createdAt: z.date(),
+ updatedAt: z.date(),
+ reviewedAt: z.date().nullable(),
+ rejectionReason: z.string().nullable(),
+ rejectionNote: z.string().nullable(),
+
+ partner: PartnerSchema.pick({
+ id: true,
+ name: true,
+ email: true,
+ image: true,
+ payoutsEnabledAt: true,
+ }),
+ commission: CommissionSchema.pick({
+ id: true,
+ amount: true,
+ earnings: true,
+ status: true,
+ }),
+ user: UserSchema.pick({
+ id: true,
+ name: true,
+ email: true,
+ image: true,
+ }),
+});
diff --git a/apps/web/lib/zod/schemas/users.ts b/apps/web/lib/zod/schemas/users.ts
new file mode 100644
index 0000000000..4d95728491
--- /dev/null
+++ b/apps/web/lib/zod/schemas/users.ts
@@ -0,0 +1,7 @@
+import { z } from "zod";
+
+export const UserSchema = z.object({
+ id: z.string(),
+ name: z.string().nullable(),
+ image: z.string().nullable(),
+});
diff --git a/packages/prisma/schema/bounty.prisma b/packages/prisma/schema/bounty.prisma
index b31e9977fa..0a14d94384 100644
--- a/packages/prisma/schema/bounty.prisma
+++ b/packages/prisma/schema/bounty.prisma
@@ -46,7 +46,7 @@ model BountySubmission {
description String? @db.Text
status BountySubmissionStatus @default(pending)
rejectionReason String?
- rejectionNotes String? @db.Text
+ rejectionNote String? @db.Text
reviewedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt