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.

adjust the schema

Kiran K6895c9d9e79f
diff --git a/apps/web/app/(ee)/api/bounties/[bountyId]/submissions/route.ts b/apps/web/app/(ee)/api/bounties/[bountyId]/submissions/route.ts
index e349ec2956..0d296e93ad 100644
--- a/apps/web/app/(ee)/api/bounties/[bountyId]/submissions/route.ts
+++ b/apps/web/app/(ee)/api/bounties/[bountyId]/submissions/route.ts
@@ -1,7 +1,7 @@
import { DubApiError } from "@/lib/api/errors";
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 { BountySubmissionExtendedSchema } from "@/lib/zod/schemas/bounties";
import { prisma } from "@dub/prisma";
import { Bounty, BountyGroup, BountyType } from "@dub/prisma/client";
import { NextResponse } from "next/server";
@@ -36,7 +36,7 @@ export const GET = withWorkspace(async ({ workspace, params }) => {
? await getSubmissions(bounty)
: await getActivePartners(bounty);
- return NextResponse.json(z.array(BountySubmissionSchema).parse(results));
+ return NextResponse.json(z.array(BountySubmissionExtendedSchema).parse(results));
});
// Get the submissions for a bounty of the type `submission`
diff --git a/apps/web/app/(ee)/api/partner-profile/programs/[programId]/bounties/route.ts b/apps/web/app/(ee)/api/partner-profile/programs/[programId]/bounties/route.ts
index d8b87f0ca0..3c8ff9ba2c 100644
--- a/apps/web/app/(ee)/api/partner-profile/programs/[programId]/bounties/route.ts
+++ b/apps/web/app/(ee)/api/partner-profile/programs/[programId]/bounties/route.ts
@@ -38,6 +38,8 @@ export const GET = withPartnerProfile(async ({ partner, params }) => {
},
});
+ console.log(bounties)
+
return NextResponse.json(
z.array(BountyWithSubmissionsSchema).parse(bounties),
);
diff --git a/apps/web/lib/types.ts b/apps/web/lib/types.ts
index 8ebeb03446..9f683371d2 100644
--- a/apps/web/lib/types.ts
+++ b/apps/web/lib/types.ts
@@ -27,7 +27,7 @@ import {
BountySchema,
BountySchemaExtended,
bountyStatsSchema,
- BountySubmissionSchema,
+ BountySubmissionExtendedSchema,
BountyWithSubmissionsSchema,
SUBMISSION_REQUIREMENTS,
} from "./zod/schemas/bounties";
@@ -533,7 +533,7 @@ export type BountyWithSubmissionsProps = z.infer<
typeof BountyWithSubmissionsSchema
>;
-export type BountySubmissionProps = z.infer<typeof BountySubmissionSchema>;
+export type BountySubmissionProps = z.infer<typeof BountySubmissionExtendedSchema>;
export type BountySubmissionRequirement =
(typeof SUBMISSION_REQUIREMENTS)[number];
diff --git a/apps/web/lib/zod/schemas/bounties.ts b/apps/web/lib/zod/schemas/bounties.ts
index 08fcbfa8da..90fd5426bb 100644
--- a/apps/web/lib/zod/schemas/bounties.ts
+++ b/apps/web/lib/zod/schemas/bounties.ts
@@ -72,21 +72,21 @@ export const BountySubmissionFileSchema = z.object({
size: z.number(),
});
-export const BountySubmissionSchema = z.object({
- submission: z
- .object({
- id: z.string(),
- description: z.string().nullable(),
- urls: z.array(z.string()).nullable(),
- files: z.array(BountySubmissionFileSchema).nullable(),
- status: z.nativeEnum(BountySubmissionStatus),
- createdAt: z.date(),
- updatedAt: z.date(),
- reviewedAt: z.date().nullable(),
- rejectionReason: z.string().nullable(),
- rejectionNote: z.string().nullable(),
- })
- .nullable(),
+const BountySubmissionSchema = z.object({
+ id: z.string(),
+ description: z.string().nullable(),
+ urls: z.array(z.string()).nullable(),
+ files: z.array(BountySubmissionFileSchema).nullable(),
+ status: z.nativeEnum(BountySubmissionStatus),
+ createdAt: z.date(),
+ updatedAt: z.date(),
+ reviewedAt: z.date().nullable(),
+ rejectionReason: z.string().nullable(),
+ rejectionNote: z.string().nullable(),
+});
+
+export const BountySubmissionExtendedSchema = z.object({
+ submission: BountySubmissionSchema.nullable(),
partner: EnrolledPartnerSchema.pick({
id: true,
name: true,
@@ -117,13 +117,7 @@ export const BountySubmissionSchema = z.object({
});
export const BountyWithSubmissionsSchema = BountySchema.extend({
- submissions: z.array(
- BountySubmissionSchema.omit({
- partner: true,
- commission: true,
- user: true,
- }),
- ),
+ submissions: z.array(BountySubmissionSchema).nullable(),
});
export const BOUNTIES_MAX_PAGE_SIZE = 100;