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.

Return the reapplication timeframe in the partner programs API

Rafid72c47a96e82
diff --git a/apps/web/app/(ee)/api/partner-profile/programs/route.ts b/apps/web/app/(ee)/api/partner-profile/programs/route.ts
index dd08208ebe..8e0dce9387 100644
--- a/apps/web/app/(ee)/api/partner-profile/programs/route.ts
+++ b/apps/web/app/(ee)/api/partner-profile/programs/route.ts
@@ -1,8 +1,10 @@
import { getProgramEnrollmentsWhere } from "@/lib/api/partner-profile/get-program-enrollments-where";
import { withPartnerProfile } from "@/lib/auth/partner";
import { prisma } from "@/lib/prisma";
-import { partnerProfileProgramsQuerySchema } from "@/lib/zod/schemas/partner-profile";
-import { ProgramEnrollmentSchema } from "@/lib/zod/schemas/programs";
+import {
+ PartnerProfileProgramEnrollmentSchema,
+ partnerProfileProgramsQuerySchema,
+} from "@/lib/zod/schemas/partner-profile";
import { Reward } from "@prisma/client";
import { NextResponse } from "next/server";
import * as z from "zod/v4";
@@ -102,5 +104,7 @@ export const GET = withPartnerProfile(async ({ partner, searchParams }) => {
};
});
- return NextResponse.json(z.array(ProgramEnrollmentSchema).parse(response));
+ return NextResponse.json(
+ z.array(PartnerProfileProgramEnrollmentSchema).parse(response),
+ );
});
diff --git a/apps/web/lib/swr/use-program-enrollments.ts b/apps/web/lib/swr/use-program-enrollments.ts
index 35c3cf6a61..ab6ef5595d 100644
--- a/apps/web/lib/swr/use-program-enrollments.ts
+++ b/apps/web/lib/swr/use-program-enrollments.ts
@@ -2,7 +2,7 @@ import { fetcher } from "@dub/utils";
import { useSession } from "next-auth/react";
import useSWR from "swr";
import * as z from "zod/v4";
-import { ProgramEnrollmentProps } from "../types";
+import { PartnerProfileProgramEnrollmentProps } from "../types";
import { partnerProfileProgramsQuerySchema } from "../zod/schemas/partner-profile";
export default function useProgramEnrollments(
@@ -15,7 +15,7 @@ export default function useProgramEnrollments(
data: programEnrollments,
isLoading,
error,
- } = useSWR<ProgramEnrollmentProps[]>(
+ } = useSWR<PartnerProfileProgramEnrollmentProps[]>(
partnerId &&
`/api/partner-profile/programs?${new URLSearchParams(
Object.fromEntries(
diff --git a/apps/web/lib/types.ts b/apps/web/lib/types.ts
index 44d4826896..0fb0cba36e 100644
--- a/apps/web/lib/types.ts
+++ b/apps/web/lib/types.ts
@@ -5,12 +5,13 @@ import {
PartnerEarningsSchema,
partnerPayoutMethodSchema,
PartnerProfileCustomerSchema,
+ partnerProfileEarningsAnalyticsQuerySchema,
PartnerProfileEarningsSchema,
PartnerProfileLinkSchema,
+ PartnerProfileProgramEnrollmentSchema,
PartnerProfileTopLinkEarningsSchema,
PartnerProfileTopProgramEarningsSchema,
PartnerProfileTypeEarningsSchema,
- partnerProfileEarningsAnalyticsQuerySchema,
partnerSubmittedLeadsCountByStatusSchema,
partnerUserSchema,
} from "@/lib/zod/schemas/partner-profile";
@@ -637,6 +638,10 @@ export type ProgramApplicationFormFieldWithValues = z.infer<
typeof programApplicationFormFieldWithValuesSchema
>;
export type ProgramEnrollmentProps = z.infer<typeof ProgramEnrollmentSchema>;
+
+export type PartnerProfileProgramEnrollmentProps = z.infer<
+ typeof PartnerProfileProgramEnrollmentSchema
+>;
export type EligibilityConditionDB = z.infer<typeof eligibilityConditionSchema>;
export type ApplicationRequirementsDB = z.infer<
typeof applicationRequirementsSchema
diff --git a/apps/web/lib/zod/schemas/partner-profile.ts b/apps/web/lib/zod/schemas/partner-profile.ts
index 27e9853421..ac58d054ee 100644
--- a/apps/web/lib/zod/schemas/partner-profile.ts
+++ b/apps/web/lib/zod/schemas/partner-profile.ts
@@ -14,6 +14,7 @@ import {
PartnerProfileType,
PartnerRole,
ProgramEnrollmentStatus,
+ ReapplicationTimeframe,
SubmittedLeadStatus,
} from "@prisma/client";
import * as z from "zod/v4";
@@ -30,7 +31,7 @@ import { DiscountSchema } from "./discount";
import { LinkSchema } from "./links";
import { getPaginationQuerySchema } from "./misc";
import { payoutsQuerySchema } from "./payouts";
-import { ProgramSchema } from "./programs";
+import { ProgramEnrollmentSchema, ProgramSchema } from "./programs";
import { RewardSchema } from "./rewards";
import { submittedLeadFormDataSchema } from "./submitted-lead-form";
import { centsSchema } from "./utils";
@@ -233,6 +234,13 @@ export const partnerProfileEventsQuerySchema = eventsQuerySchema.omit({
folderId: true,
});
+// GET /api/partner-profile/programs adds the reapplication timeframe, so that
+// a rejected program can say when the partner can apply again
+export const PartnerProfileProgramEnrollmentSchema =
+ ProgramEnrollmentSchema.extend({
+ reapplicationTimeframe: z.enum(ReapplicationTimeframe).nullish(),
+ });
+
export const partnerProfileProgramsQuerySchema = z.object({
includeRewardsDiscounts: z.coerce.boolean().optional(),
// one status or a comma-separated list, for example "pending,rejected"