The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Refactor commission type handling to use native enum from Prisma.
Kiran K0b471d68a5cd
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-composite-chart.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-composite-chart.tsxindex bf793616c2..f4675b37b2 100644--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-composite-chart.tsx+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-composite-chart.tsx@@ -22,6 +22,7 @@ import {nFormatter,} from "@dub/utils";import NumberFlow from "@number-flow/react";+import { CommissionType } from "@prisma/client";import { endOfDay, startOfDay } from "date-fns";import { Fragment, useMemo, useState } from "react";@@ -278,10 +279,10 @@ function EarningsTableControls() {key: "type",icon: Sliders,label: "Type",- options: ["click", "lead", "sale"].map((slug) => ({- value: slug,- label: capitalize(slug) as string,- icon: <CommissionTypeIcon type={slug} />,+ options: Object.values(CommissionType).map((type) => ({+ value: type,+ label: capitalize(type) as string,+ icon: <CommissionTypeIcon type={type} />,})),},{diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/use-commission-filters.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/use-commission-filters.tsxindex 5ee64d29e3..bb19d00ee1 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/use-commission-filters.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/use-commission-filters.tsx@@ -11,6 +11,7 @@ import { CommissionStatusBadges } from "@/ui/partners/commission-status-badges";import { CircleDotted, useRouterStuff } from "@dub/ui";import { Sliders, User, Users } from "@dub/ui/icons";import { capitalize, cn, nFormatter, OG_AVATAR_URL } from "@dub/utils";+import { CommissionType } from "@prisma/client";import { useCallback, useMemo, useState } from "react";import { useDebounce } from "use-debounce";@@ -76,10 +77,10 @@ export function useCommissionFilters() {key: "type",icon: Sliders,label: "Type",- options: ["click", "lead", "sale", "custom"].map((slug) => ({- value: slug,- label: capitalize(slug) as string,- icon: <CommissionTypeIcon type={slug} />,+ options: Object.values(CommissionType).map((type) => ({+ value: type,+ label: capitalize(type),+ icon: <CommissionTypeIcon type={type} />,})),},{diff --git a/apps/web/lib/zod/schemas/partner-profile.ts b/apps/web/lib/zod/schemas/partner-profile.tsindex aa7e4cada3..d51550d7e3 100644--- a/apps/web/lib/zod/schemas/partner-profile.ts+++ b/apps/web/lib/zod/schemas/partner-profile.ts@@ -2,6 +2,7 @@ import {DATE_RANGE_INTERVAL_PRESETS,DUB_PARTNERS_ANALYTICS_INTERVAL,} from "@/lib/analytics/constants";+import { CommissionType } from "@prisma/client";import { z } from "zod";import { analyticsQuerySchema, eventsQuerySchema } from "./analytics";import {@@ -43,7 +44,7 @@ export const getPartnerEarningsQuerySchema = getCommissionsQuerySchemainterval: z.enum(DATE_RANGE_INTERVAL_PRESETS).default(DUB_PARTNERS_ANALYTICS_INTERVAL),- type: z.enum(["click", "lead", "sale"]).optional(),+ type: z.nativeEnum(CommissionType).optional(),linkId: z.string().optional(),sortBy: z.enum(["createdAt", "amount", "earnings"]).default("createdAt"),}),@@ -58,7 +59,7 @@ export const getPartnerEarningsCountQuerySchema = getCommissionsCountQuerySchemainterval: z.enum(DATE_RANGE_INTERVAL_PRESETS).default(DUB_PARTNERS_ANALYTICS_INTERVAL),- type: z.enum(["click", "lead", "sale"]).optional(),+ type: z.nativeEnum(CommissionType).optional(),linkId: z.string().optional(),groupBy: z.enum(["linkId", "customerId", "status", "type"]).optional(),}),