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.

Parse includeRewardsDiscounts=false as false in the programs API

Rafi69ad386e02c1
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/page-client.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/page-client.tsx
index 7bd5977f8e..a81c8ba787 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/page-client.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/page-client.tsx
@@ -155,9 +155,8 @@ function ProgramsGridSkeleton() {
function ProgramsGrid({ tab, search }: { tab: ProgramTab; search?: string }) {
const { programEnrollments, isLoading } = useProgramEnrollments({
- // only the invite cards show the rewards and the discount. Leave the
- // parameter out otherwise, because the API reads "false" as true.
- ...(tab.id === "invitations" && { includeRewardsDiscounts: true }),
+ // only the invite cards show the rewards and the discount
+ includeRewardsDiscounts: tab.id === "invitations",
status: tab.statuses.join(","),
search,
});
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/programs-table.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/programs-table.tsx
index 3c94e9a307..f19aa9b0a7 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/programs-table.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/programs-table.tsx
@@ -52,7 +52,7 @@ export function ProgramsTable({
const status = tab.statuses.join(",");
const { programEnrollments, isLoading, error } = useProgramEnrollments({
- ...(tab.id === "invitations" && { includeRewardsDiscounts: true }),
+ includeRewardsDiscounts: tab.id === "invitations",
status,
search,
...(sortBy && { sortBy }),
diff --git a/apps/web/lib/swr/use-program-enrollments.ts b/apps/web/lib/swr/use-program-enrollments.ts
index ab6ef5595d..cdc71db759 100644
--- a/apps/web/lib/swr/use-program-enrollments.ts
+++ b/apps/web/lib/swr/use-program-enrollments.ts
@@ -6,7 +6,10 @@ import { PartnerProfileProgramEnrollmentProps } from "../types";
import { partnerProfileProgramsQuerySchema } from "../zod/schemas/partner-profile";
export default function useProgramEnrollments(
- query: z.input<typeof partnerProfileProgramsQuerySchema> = {},
+ query: Omit<
+ z.input<typeof partnerProfileProgramsQuerySchema>,
+ "includeRewardsDiscounts"
+ > & { includeRewardsDiscounts?: boolean } = {},
) {
const { data: session } = useSession();
const partnerId = session?.user?.["defaultPartnerId"];
diff --git a/apps/web/lib/zod/schemas/partner-profile.ts b/apps/web/lib/zod/schemas/partner-profile.ts
index ac58d054ee..9f93a8d4c9 100644
--- a/apps/web/lib/zod/schemas/partner-profile.ts
+++ b/apps/web/lib/zod/schemas/partner-profile.ts
@@ -29,7 +29,7 @@ import { customerActivityResponseSchema } from "./customer-activity";
import { CustomerEnrichedSchema } from "./customers";
import { DiscountSchema } from "./discount";
import { LinkSchema } from "./links";
-import { getPaginationQuerySchema } from "./misc";
+import { booleanQuerySchema, getPaginationQuerySchema } from "./misc";
import { payoutsQuerySchema } from "./payouts";
import { ProgramEnrollmentSchema, ProgramSchema } from "./programs";
import { RewardSchema } from "./rewards";
@@ -242,7 +242,7 @@ export const PartnerProfileProgramEnrollmentSchema =
});
export const partnerProfileProgramsQuerySchema = z.object({
- includeRewardsDiscounts: z.coerce.boolean().optional(),
+ includeRewardsDiscounts: booleanQuerySchema.optional(),
// one status or a comma-separated list, for example "pending,rejected"
status: z
.string()